c - Expand __COUNTER__ macro once per source file -


i'm trying write macro expand __counter__ macro once per source file. understand how macros work expansion i'm having difficulty one. want expand __counter__ macro once @ top of file , each reference define not expand __counter__ it's next number.

so want expand __counter__ single value , use 1 value consistently through current working source file.

i can use features available c.

the __counter__ extension (i suppose using compiler gcc family) restricted such use. difficulty if put macro, toto, not expanded @ definition @ use. each invocation of toto give rise new value of counter.

in p99 have portable replacement this, achieves goal #include hackery. p99_fileid per file identifier, , p99_lineid id should unique lines in compilation unit (but use care).

another alternative if need compile time constant , nothing in preprocessor use counter in enumeration constant.

enum { toto_id = __count__, };  

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -