Book a Demo

Author Topic: C++ #include statements generated with paths  (Read 3015 times)

wsproule

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
C++ #include statements generated with paths
« on: March 04, 2006, 07:45:11 pm »
I'm using registered EA version 6.1.786.

When I generate C++ code for a class, the .h file has #include statements with paths relative to the root folder I'm generating into and the .cpp file has #include statements with no paths (just filename).  Please see red below.  As a result the .h files generate errors since they are located in the same directory the relative path is trying to refer to.  I've tried several variations of the generation dialog with identical results.  I've tried removing the auto generated paths in class properties and regenerating.

Known bug?  How do I work around it short of manually fixing the .h files outside of EA?  If I can change a template please provide the code.

Thanks.

///////////////////////////////////////////////////////////
//  CUIPluginMgr.h
//  Definition of the Class CUIPluginMgr
//  Created on:      04-Mar-2006 7:08:26 PM
///////////////////////////////////////////////////////////

#if !defined(EA_95C2102D_BDFE_4c95_8243_E16989A38CBB__INCLUDED_)
#define EA_95C2102D_BDFE_4c95_8243_E16989A38CBB__INCLUDED_

#include "Desktop\uiExe\CUIPluginProxy.h"


///////////////////////////////////////////////////////////
//  CUIPluginMgr.cpp
//  Implementation of the Class CUIPluginMgr
//  Created on:      04-Mar-2006 7:08:26 PM
///////////////////////////////////////////////////////////

#include "CUIPluginMgr.h"

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ #include statements generated with paths
« Reply #1 on: March 07, 2006, 07:38:12 pm »
This is happening because you have local paths defined, and it appears that at some point it was decided that where possible include paths should be generated relative to the local path in a filename.

You can override it by never calling the fileImports macro.  The following was derived from the PHP import generation code and is equivalent except that includes listed in the generation dialog are not generated.

Import Section
Code: [Select]
$imports = %list="Import" @separator="\n" importFromAggregation=="T" or importFromAssociation=="T" or importFromAtt=="T" or importFromDependency=="T" or importFromGeneralization=="T" or importFromMeth=="T" or importFromParam=="T" or importFromRealization=="T"%
%REMOVE_DUPLICATES($imports, "\n")%

Import
Code: [Select]
$file = %importFileName%
%if $file == ""%
$file = %importClassName ? value% + %genOptCPPSourceExtension%
%endIf%
%if $file == "" or importInFile=="T" or $file==fileName%
%endTemplate%

#include %qt%$file%qt%

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ #include statements generated with paths
« Reply #2 on: March 07, 2006, 08:28:50 pm »
Sorry.  The templates I gave don't actually fix the problem.  The importFileName macro does the same thing, I didn't notice that before.

The only two options that leaves you is to modify what I wrote with an EXEC_ADD_IN call to remove the relative path, or to change your usage of local paths so that only filenames will be generated.