Book a Demo

Author Topic: EA Problem: Importing c++ code  (Read 6427 times)

RoadPatcher

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
EA Problem: Importing c++ code
« on: February 23, 2007, 07:13:43 am »
Hi there,
I encountered a problem when importing c++ source code from my project with Enterprise Architect 6.5 .
In this source I use bitfields like the following one:
Code: [Select]
typedef struct {
  unsigned int   DirectionFlow:3, BlockedPassage:2,        
        FormOfWay:5,
        FzRestriction:3,
        FC:4, Net1:7,
        Delete:1,
        InOrt:1, Ferry:1, Toll:1, HN:1, RN:1, inDst:1,
        SperreLKW:1, SperreAnwohner:1;
  unsigned int Order8Id;
     const char* Name;
     int         AnzName;
} tagRoadType;


Now EA tells me:
Quote
There was an error parsing someheader.h on line 175.  Unexpected symbol: }

The mentioned line is the last one of the example. So the bracket "}" before tagRoadType is meant.

I read on the changespage that EA supports bitfields since version 4.5 .

What is wrong here?
Do I have to adjust an option?
Or change something in the source? (Better not because there are a lot of bitfields.)


Thanks in advance for your support.

RoadPatcher

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #1 on: February 27, 2007, 02:00:38 am »
Does no one has an idea how to solve the bitfield problem?

Do I have to ask somewhere else? (Where?)

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #2 on: February 27, 2007, 06:01:17 am »
Do you still get the error if all the fields are
  • just unsigned int (not bitfield)
  • declarations done separately rather than all in same statement
Does the error occur only after a certain threshold number of items ?

In other words, try making a test case to demonstrate the point at which the error shows up.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #3 on: February 27, 2007, 03:16:11 pm »
It appears that the error is the combination of the bitfields and the multiple variables in one declaration.

This will be fixed in a future build.

RoadPatcher

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #4 on: February 28, 2007, 12:35:54 am »
Quote
It appears that the error is the combination of the bitfields and the multiple variables in one declaration.

This will be fixed in a future build.


Thanks for your answer.
As we use lots of these declarations the support of them is a criteria whether to buy a license or not.
(We can't simply rewrite them!)

At the moment we are evaluating your product and some others.
I hope you can fix it soon. :)

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #5 on: February 28, 2007, 01:58:19 am »
However it appears there is a simple workaround, and it's probably better/clearer style to have each field declared as a separate item in any case.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #6 on: February 28, 2007, 01:14:01 pm »
It will be fixed, (regardless of you buying or not buying a license or not)

One thing to note is that EA can't forward synchronise with that format.  If any of the attributes change it will break them all up and regenerate them.

mbc

  • EA User
  • **
  • Posts: 237
  • Karma: +1/-0
  • Embedded software developer
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #7 on: March 05, 2007, 06:13:52 am »
I have another recommendation for you, although I realize that if you are stuck with a lot of legacy code it might not be an option.
The "typedef struct {int i;} xxx;" is obsolete in c++.

Just use "struct xxx {int i;};" instead;

Best regards
Mikkel

sl@sh

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #8 on: March 06, 2007, 12:32:57 am »
Not only that - try to forward-declare such a struct! You will find that it is virtually impossible to do that with a typedef'ed name. You actually need to use the current C++ syntax.

For instance look at this:
Code: [Select]
struct xxx;
xxx* createXXX();
typedef struct xxx
{
   int i;
} txxx;
txxx a;

The first line is a forward declaration that is needed to declare the function, createXXX(). Try replacing that forward declaration with 'txxx'. If you do you will get various error messages, most likely this one: error C2371: 'txxx' : redefinition; different basic types

The only way (I know of) to use a typedef'ed struct name before the actual struct declaration is like this:
Code: [Select]
typedef struct xxx txxx;
txxx* createXXX();
struct xxx
{
   int i;
};
txxx a;

And when you do this you can actually omit the typedef without a loss ... ;)

However, if you're stuck with legacy code you probably don't have to cope with forward declarations anyway :)

RoadPatcher

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: EA Problem: Importing c++ code
« Reply #9 on: March 06, 2007, 03:46:01 am »
@slash: I don't like forward-declaration. If you could see what it done to our project you would not, too.
It's really horrible when only the linker realizes that the class was never defined in the manner the headers are included. You can sometimes spend a lot of time to fix this properly (means with minimal includes).  :-/
« Last Edit: March 06, 2007, 03:46:56 am by RoadPatcher »