Book a Demo

Author Topic: Using pragma once directive in C++ code generation  (Read 3614 times)

Eiberle

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Using pragma once directive in C++ code generation
« on: July 26, 2011, 08:35:07 pm »
Hi,
I am using VC2010 and with this version you can use the #pragma once directive in a header to specify that the file will be included only once by the compiler.

The EA code generation template for C++ (EA vesion 9.0 Build 908) uses still, the

#if !defined(EA_SomGUID__INCLUDED_)
#define EA_SomGUID__INCLUDED_
class xyz
{}
#endif // !defined(EA_SomGUID__INCLUDED_)


convention to do the same thing.

I wanted to change this, but in the 'File' code template for C++ I found the Comment not to alter it:

$COMMENT="WARNING: DO NOT MODIFY THIS TEMPLATE BELOW THIS POINT"
$guid = "EA_" + %TRIM(eaGUID,"{}")%
$guid = %REPLACE($guid,"-","_")%
$guid += "__INCLUDED_"
#if !defined($guid)
#define $guid\n
%ImportSection%
%list="Namespace" @separator="\n\n"%
#endif // !defined($guid)\n


Has anybody an idea why this is not allowed, or how I can manage to change the code generation to use the pragma once directive instead of the define?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Using pragma once directive in C++ code genera
« Reply #1 on: July 27, 2011, 08:20:31 am »
Go ahead and alter it.

Just keep

Code: [Select]
%ImportSection%
%list="Namespace" @separator="\n\n"%

Eiberle

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Using pragma once directive in C++ code genera
« Reply #2 on: July 27, 2011, 03:13:35 pm »
Great, it works like expected.

Thanks.