Backslash newline at end of file warning

后端 未结 6 1624
猫巷女王i
猫巷女王i 2020-12-20 12:59

With this code:

#include 


int main(int argc, char *argv[])
{

  return 0;
}


/** run2: A macro to call a function. */
#define run2( functi         


        
6条回答
  •  失恋的感觉
    2020-12-20 13:40

    The following code generates the same warning under g++ 4.3.4 and g++ 4.5.1:

    int main() {}
    #define X \
    Y
    

    I must say I don't understand why. But you can get rid of the warning by adding an empty line at the end of the file.

    Incidentally, this compiles without a warning, even without an empty last line:

    int main() {}
    #define X Y
    

    So it looks like a pre-processor bug to me.

    Edited to add: OK, not a bug as such. See my other answer for a more considered view.

提交回复
热议问题