Invalid preprocessor error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saddique
    New Member
    • Dec 2011
    • 1

    Invalid preprocessor error

    I am trying to use "::" in preprocessor directive but am continously getting error for invalid preprocessor directive. can any one tell me replacement of "::"

    Code:
    #include <iostream>
    #include <string.h>
    
    #define MACRO(arg) string(::arg)
    
    using namespace std;
    
    int main()
    {
       cout<<MACRO(xyz);
       return 0;
    }

    error: pasting "::" and "xyz" does not give a valid preprocessing token
    Last edited by Meetee; Dec 16 '11, 08:18 AM. Reason: code tags added
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    It isn't clear what you are trying to achieve using a :: in that location

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Also. there's no xyz to use to expand the macro.

      Also, <string.h> is for C. <string> is for C++.

      Comment

      Working...