This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Does g++ have a intel/msdn __COUNTER__ macro equivalent??
- From: me <mgbg25171 at blueyonder dot co dot uk>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 04 Sep 2007 10:04:51 +0100
- Subject: Does g++ have a intel/msdn __COUNTER__ macro equivalent??
Dear Sir/Madam
I'm trying to specify random distributions throughout my program eg
Uniform(1,0), Normal(10,2).
Id like these replaced at the pre-processing stage with
Uniform(__COUNTER__,1,0) & Normal(__COUNTER__,10,2) using macros such as
#define U(a,b) U(__COUNTER__,a,b) etc
The point of this is that __COUNTER__ would assign consecutive numbers
representing the index of the random number generator to be used.
Here is a description of Microsoft's version of __COUNTER__ &
I believe that Intel also has such a facility.
========================================================================
Expands to an integer starting with 0 and incrementing by 1 every time
it is used in a compiland. __COUNTER__ remembers its state when using
precompiled headers. If the last __COUNTER__ value was 4 after building
a precompiled header (PCH), it will start with 5 on each PCH use.
__COUNTER__ lets you generate unique variable names. You can use token
pasting with a prefix to make a unique name. For example:
// pre_mac_counter.cpp
#include <stdio.h>
#define FUNC2(x,y) x##y
#define FUNC1(x,y) FUNC2(x,y)
#define FUNC(x) FUNC1(x,__COUNTER__)
int FUNC(my_unique_prefix);
int FUNC(my_unique_prefix);
int main() {
my_unique_prefix0 = 0;
printf_s("\n%d",my_unique_prefix0);
my_unique_prefix0++;
printf_s("\n%d",my_unique_prefix0);
}
========================================================================
I can not find g++'s equivalent & wonder how I could achieve the same
thing?
Your consideration of this matter is much appreciated.
Best Rgds
Dean