Compiler macros

Everything else that doesn't fall into one of the other PB categories.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Compiler macros

Post by SFSxOI »

MS compilers have pre-defined macros like the (_WIN64) macro. Never thought about it before, but I was wondering what predefined, if any, macros the PB compiler has?
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Compiler macros

Post by Shield »

There are pre-defined constants, e.g. #PB_COMPILER_DATE that do the same job.
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Compiler macros

Post by freak »

quidquid Latine dictum sit altum videtur
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Compiler macros

Post by c4s »

Offtopic:
@freak
Adding html anchors to the online and offline help would be useful. This way e.g. http://www.purebasic.com/documentation/ ... -constants or selecting the title from the navigation menu would directly jump to the bottom. It can be easily implemented using the id attribute (info here: http://www.w3.org/TR/html4/struct/links.html#h-12.2.3).
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: Compiler macros

Post by SFSxOI »

Thanks for the replys folks, not exactly what I was talking about but close enough I guess. :)
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: Compiler macros

Post by xorc1zt »

pb devs should add the macro __COUNTER__ which could be usefull.

Code: Select all

#include <stdio.h>

int curCounter = 0;

#define RESET_COUNTER curCounter = __COUNTER__ + 1
#define GET_COUNTER __COUNTER__ - curCounter

int main()
{
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   RESET_COUNTER;
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   RESET_COUNTER;
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   printf (" %d\n", GET_COUNTER );
   return 0;
}
result
0
1
2
3
4
5

0
1
2

0
1
2
3
4
5
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Compiler macros

Post by c4s »

@xorc1zt
Well, there is the #PB_Compiler_EnumerationValue constant. Not exactly what you wanted but maybe you didn't know it so far:

Code: Select all

  Enumeration
    #GadgetInfo ; Will be 0
    #GadgetText ; Will be 1
    #GadgetOK   ; Will be 2
  EndEnumeration
  
  Enumeration #PB_Compiler_EnumerationValue
    #GadgetCancel ; Will be 3
    #GadgetImage  ; Will be 4
    #GadgetSound  ; Will be 5
  EndEnumeration
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Post Reply