Re: [Freeciv-Dev] Permission to make freeciv headers standard C/C++ compatible.

2007-06-04 Thread Per I. Mathisen
On Mon, 4 Jun 2007, James Supancic wrote:
> Even with -fpermissive g++ rejects it. I moved the enum typedef from
> fc_types.h to unit.h (after the enum declaration)

Committed. (Though, actually, I did it the other way around.)

> It looks like the attached patch does what I need (as far as I know at
> this point). Basically I use an #ifdef __cplusplus to change the name
> of identifiers that that conflict with C++ reserved keywords only when
> building with a C++ compiler. This way none of the freeciv .c files
> have to be modified.

That is an ugly hack. Let's just do it right, and rename "class" to, say, 
"unitclass" (or "unit_class"?) throughout the code instead.

   - Per

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] Permission to make freeciv headers standard C/C++ compatible.

2007-06-04 Thread James Supancic

Even with -fpermissive g++ rejects it. I moved the enum typedef from
fc_types.h to unit.h (after the enum declaration) and did 'make clean
&& make' and everything builds fine.

It looks like the attached patch does what I need (as far as I know at
this point). Basically I use an #ifdef __cplusplus to change the name
of identifiers that that conflict with C++ reserved keywords only when
building with a C++ compiler. This way none of the freeciv .c files
have to be modified.

Thank you for your time,
James Steven Supancic III


freecivcppcompt.patch
Description: Binary data
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] Permission to make freeciv headers standard C/C++ compatible.

2007-06-03 Thread Per I. Mathisen
On Sun, 3 Jun 2007, James Supancic wrote:
> I'm working on a C++ GUI for freeciv. I need to make some calls into
> the C component of client. The problem I'm running into is that the
> freeciv header files are neither standard C or C++ compatible.
>
> For example:
> typedef enum a b;
> enum a { A, B };
>
> When this is compiled with g++ or 'gcc -pedantic' there will be an
> error, if it is compiled with gcc there will be no error.
>
> Given this problem, I see three possible solutions:
> 1) Quit
> 2) update the freeciv headers
> 3) write a C++ compatible wrapper for the functions I need.
>
> #3 would be the easiest in the short term

I am sure #1 is easiest in the short term ;-)

More seriously - does it work if you compile with g++ using -fpermissive? 
If not, I'd say #2 is the best solution. But I would like to see a patch 
for some header files first, to see how invasive the required changes are.

> refactoring the code to eliminate the use of 'class' as an identifier 
> (as this is a C++ reserved keyword), perhaps other things.

C++ reserved keywords should be avoided, I agree.

   - Per

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] Permission to make freeciv headers standard C/C++ compatible.

2007-06-03 Thread Vasco Alexandre da Silva Costa

On 6/3/07, James Supancic <[EMAIL PROTECTED]> wrote:


I'm working on a C++ GUI for freeciv. I need to make some calls into
the C component of client. The problem I'm running into is that the
freeciv header files are neither standard C or C++ compatible.

For example:
typedef enum a b;
enum a { A, B };

When this is compiled with g++ or 'gcc -pedantic' there will be an
error, if it is compiled with gcc there will be no error.



Why even compile with -pedantic in the first place?

Given this problem, I see three possible solutions:

1) Quit
2) update the freeciv headers
3) write a C++ compatible wrapper for the functions I need.

#3 would be the easiest in the short term, but long term it will
require a significant amount of additional work to maintain. #2 is the
best in the long term, but has significant dangers. In updating the
headers, I could possibly introduce bugs or break features.

I'd like to do #2, with permission from the freeciv development team.
However, I'm also willing to do #3 if they feel it is unsafe.

#2 will probably involve me moving around some typedefs so that they
don't come before enum declarations and refactoring the code to
eliminate the use of 'class' as an identifier (as this is a C++
reserved keyword), perhaps other things.

Thank you for your time,
James Steven Supancic III

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev





--
Vasco Alexandre da Silva Costa
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] Permission to make freeciv headers standard C/C++ compatible.

2007-06-03 Thread James Supancic
I'm working on a C++ GUI for freeciv. I need to make some calls into
the C component of client. The problem I'm running into is that the
freeciv header files are neither standard C or C++ compatible.

For example:
typedef enum a b;
enum a { A, B };

When this is compiled with g++ or 'gcc -pedantic' there will be an
error, if it is compiled with gcc there will be no error.

Given this problem, I see three possible solutions:
1) Quit
2) update the freeciv headers
3) write a C++ compatible wrapper for the functions I need.

#3 would be the easiest in the short term, but long term it will
require a significant amount of additional work to maintain. #2 is the
best in the long term, but has significant dangers. In updating the
headers, I could possibly introduce bugs or break features.

I'd like to do #2, with permission from the freeciv development team.
However, I'm also willing to do #3 if they feel it is unsafe.

#2 will probably involve me moving around some typedefs so that they
don't come before enum declarations and refactoring the code to
eliminate the use of 'class' as an identifier (as this is a C++
reserved keyword), perhaps other things.

Thank you for your time,
James Steven Supancic III

___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev