1

Is there anything equivalent to #pragma once for Codegear RAD Studio 2009?

I am using the precompiled header wizard and I would like to know if it is still necessary to use include guards when including header files?

Johan
  • 74,508
  • 24
  • 191
  • 319
Seth
  • 8,213
  • 14
  • 71
  • 103

2 Answers2

5

Support for #pragma once was added in C++Builder 2010 In C++Builder 2009 and earlier, the unknown pragma will simply be ignored. I would suggest using

#ifndef X 
#define X
//code 
#endif

style header guards in the versions of C++Builder that do not support #pragma once.

David Dean
  • 2,682
  • 23
  • 34
1

Rad Studio supports #pragma once, along with all of the following.

JRL
  • 76,767
  • 18
  • 98
  • 146
  • Excellent. The installed help must have been out of date. – Seth Feb 09 '10 at 06:32
  • 1
    Please note that support for #pragma once was only added in C++Builder 2010 and was not available in C++Builder 2009 and earlier. – David Dean Feb 09 '10 at 16:29
  • oh in that case - unmarking as correct answer. @David you should post that comment as the correct answer. – Seth Feb 09 '10 at 22:49
  • @David see follow up question regarding if 2009 has header-include-guard-optimisation, even though it doesn't use the `#pragma once` directive. http://stackoverflow.com/questions/2233401/are-redundant-include-guards-necessary – Seth Feb 10 '10 at 00:11
  • I'm not getting anything under http://docwiki.embarcadero.com/RADStudio/en/Pragma_Directives_Overview_Index -> 503 Service Unavailable – Wolf Nov 21 '17 at 15:28