Menu

#pragma directive

2005-09-08
2012-09-26
  • Nobody/Anonymous

    why DevCpp does not have support to this this directive?
    I got a baunch of sources w/ #pragma once, pack directives.
    how can i bzpass or replace this directive?

     
    • Ian Walker

      Ian Walker - 2005-09-08

      Most #pragmas are compiler specific, and your code most probably came from someone developing with MS Visual C++.

      Normally, any compiler should ignore a #pragma that it doesn't recognise. However, GCC can be told to issue a warning for unknown #pragmas, with the -Wunknown-pragmas, which is also enabled by the -Wall option. If you have -Wall -Werror specified then the compiler should halt. You can change your options to -Wall -Werror -Wno-unknown-pragmas to fix this.

      GCC (the compiler inside Dev-C++) doesn't really utilise #pragmas - see http://gcc.gnu.org/onlinedocs/gcc-3.4.4/cpp/Pragmas.html#Pragmas for details.

      I would suggest that you comment them out, using C++ style comments "//" before each one. If it still compiles and runs correctly, you have two choices:

      1) If the code is not shared with other people using a different compiler, just leave it.

      2) If you need to merge the changes back to a shared project, surround the #pragmas with a guard, such as:

      ifndef GNUC

      pragma pack whatever

      endif

      If it doesn't work, you're going to need to work out why those pragmas are there, and speak to the developer about replacing them with something cross-platform. Good luck.

      Cheers,

      Ian

       
    • Nobody/Anonymous

      thanks .

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.