
21 Apr
2004
21 Apr
'04
10:35 p.m.
"Arkadiy Vertleyb" <vertleyb@hotmail.com> wrote: [snip __COUNTER__ macro question]
Actually I don't need to have many things on the same line, but I do want to handle inclusions from several headers... Maybe it's somehow possible to generate a unique number from the header file name? Or use this #include mechanism you mentioned?
__FILE__/__LINE__ combination is unique across multile TUs. But it is AFAIK impossible to translate it into numeric value (preprocessor sees string as one token) and const char* cannot be used as template parameter. Though you can name headers as hdr1.hpp, hdr2.hpp, ... and extract the unique header number via __FILE__[sizeof(__FILE__) - 6] hack to get its ASCII code. /Pavel