0

I have used following macro:

#define chSTR2(x) #x
#define chSTR1(x) chSTR2(x)
#define TODO(x) message(__FILE__"(" chSTR1(__LINE__) ") : TODO: " #x)
#define TODOEX(msg, usr) __pragma(message(__FILE__"(" chSTR1(__LINE__) ") : TODO("#usr"): " #msg))

When I try to use it inside my code like this:

TODOEX("Implement case when knzKorrIRS=j", kun01826);

And I try to compile this on Linux machine with gcc compiler (version 4.7.3) I get following error:

some_file.cpp:152:7: error: 'message' was not declared in this scope
some_file.cpp:152:7: error: '__pragma' was not declared in this scope

On my Windows machine with Microsoft compiler (Visual Studio 2013) I get no errors and everything works ok.

If I use TODO in my code in the following way

#pragma TODO(Some text)

then everything is ok (also on Linux machine with gcc).

I have tried to look for an answer but did not find anything which would explain the problem in gcc. So, can please somebody explain me what did I do wrong and how can I correct this that it would compile also on my Linux machine with gcc compiler installed.

joe_specimen
  • 295
  • 3
  • 19
  • Well, `message()` and `__pragma` are obviously MSVC extensions. You'll need to find their GCC equvalents. – πάντα ῥεῖ Feb 18 '17 at 10:27
  • @πάνταῥεῖ Yep, I saw the duplicate mark and read that __pragma is actually supported only by some of the compilers. Ok, I think this actually answers my question. I will use this stuff with #pragma it is no problem. – joe_specimen Feb 18 '17 at 11:21
  • @πάνταῥεῖ: `__pragma` is a Microsoft-specific extension. `warning`, on the other hand, is just a specific `#pragma` implementation. While Microsoft-specific as well, it's a standards compliant language construct. – IInspectable Feb 18 '17 at 11:28

0 Answers0