This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

#pragma once

Does the Ti ARM compiler in CCS support "#pragma once"? Is there a trick to turn it on? I am not seeing it working.

  • The TI compiler does support #pragma once.  What do you see which makes you think it doesn't work?  What version of the compiler do you use?

    Thanks and regards,

    -George

  • Can you point to the documentation that shows support for this?  I don't see it in the 15.12.0 compiler guide.

  • You are correct that #pragma once does not appear in the compiler manual.  I filed CODEGEN-1678 in the SDOWP system to have this addressed.  Feel free to follow it with the SDOWP link below in my signature.

    Thanks and regards,

    -George

  • Can you provide a snippet of how the compiler expects it to be used here so we at least have something to refer to?
  • An internet search on #pragma once returns many links that describe it.  Every compiler that supports it does it the same way.  It intended for use in header files.  An appearance of #pragma once in a header file means that, should the header file be included multiple times, only the first one counts.

    Thanks and regards,

    -George

  • We can't seem to get it to work.  We've had to fall back to using include guards.

  • Please try this simple experiment.  What follows is a header file, and a C source file.

    // hdr.h
    #pragma once
    #warn only see this one time
    // src.c
    #include "hdr.h"
    #include "hdr.h"
    int a;

    When you compile src.c, it should look similar to this ...

    %> armcl src.c
    "hdr.h", line 3: warning: #warn directive: only see this one time
    

    Even though hdr.h is included twice, the #warn diagnostic is emitted only once.  What happens when you try this experiment?

    Thanks and regards,

    -George