Author Topic: gcc 2.95  (Read 4706 times)

0 Members and 1 Guest are viewing this topic.

Offline fizz

  • 25
    • Crimson Fields
Hi,

I came across FS2Open recently and yesterday decided to give the CVS version a try. Unofrtunately, fs currently cannot be built with gcc 2.95, mainly because that version apparently doesn't properly separate the std namespace and therefore the vector type fs uses clashes with std::vector.

Would a patch renaming the vector type be accepted? I'll happily create one if you let me know of an acceptable alternate name.

I did have to patch a few more places, but the vector errors account for more than 99% of the changes. I haven't had the time to check whether it actually works, though :rolleyes:

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
AFAIK, vector is a fairly common name for 3D applications. Isn't there a somewhat less intrusive way of making the change? AFAIK, std::vector is only used in a few places in the code.
-C

 

Offline fizz

  • 25
    • Crimson Fields
I can't think of one (which of course doesn't mean much). The problem is that when you include <vector>, std::vector is not properly namespaced, so you basically end up with two definitions for vector.

What might be possible is to separate all uses of std::vector into their own files. They must not use the fs vector at the same time though, and this of course makes it impossible to use in header files included by other sources. And it'll break again as soon as someone not using gcc 2 crosses that fine line. I don't know the fs codebase so I'm not sure if this is feasible, but even if it was, I'm not sure it's a better solution.

EDIT: Gr... stupid HTML...

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Does -fhonor-std help any?  Never had to use it myself but a Google search turned that up.  From the docs:
Quote
Treat the namespace std as a namespace, instead of ignoring it. For compatibility with earlier versions of g++, the compiler will, by default, ignore namespace-declarations, using-declarations, using-directives, and namespace-names, if they involve std.

It will depend on how it's used in the files in question but it might make the difference and not require a ton of code changes.  I know that gcc 2.95 is still used but it's rather old at this point and unless the changes are very minor and don't require any sort of work around for other compilers then support for it will be officially dropped.  It's not worth supporting if it takes that much effort and gcc 3+ will become the minimum requirement.

 

Offline fizz

  • 25
    • Crimson Fields
That sounds like it's an option for newer g++, but I'll try it.

It would be sad to drop support for gcc 2, though, especially as there seems to be no good reason for it. Sure, the patch would touch a lot of files, but the changes are absolutely trivial and should be transparent to other compilers. As I mentioned in my first post, apart from this issue, there were only very minor corrections needed to make it compile.

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Quote
Originally posted by fizz
That sounds like it's an option for newer g++, but I'll try it.

It's from the gcc 2.xx series for backwards compatibility since older versions didn't honor the STD namespace either.  This option just turns compliance back on.  By default it's off there but in the 3.xx series I think that it's either on by default or ignored completely since it's handled properly.

Quote
It would be sad to drop support for gcc 2, though, especially as there seems to be no good reason for it. Sure, the patch would touch a lot of files, but the changes are absolutely trivial and should be transparent to other compilers. As I mentioned in my first post, apart from this issue, there were only very minor corrections needed to make it compile.

I don't want to drop support for it but I don't want to maintain support for it either.  It's been difficult enough just keeping GCC working period and to have special support for various versions just adds to the problem.  Go ahead and send the patch and if it doesn't require any additional learning for the other code monkeys then I'll gladly add it.  If there are things that everyone has to remember in the future when making changes or added new files though then I'd be less likely to put it in.

 

Offline fizz

  • 25
    • Crimson Fields
Quote
Originally posted by taylor

Go ahead and send the patch and if it doesn't require any additional learning for the other code monkeys then I'll gladly add it.  If there are things that everyone has to remember in the future when making changes or added new files though then I'd be less likely to put it in.


I do understand that, and that's why I said I don't think the second "solution" is any good. The straight solution is to just rename the vector type. After that nobody needs to remember anything (except  that it's called something else then, of course). I'll create a patch for that. Any preferred name? Maybe "vec"? Or "fsvector"?

 

Offline fizz

  • 25
    • Crimson Fields
Quote
Originally posted by taylor
Does -fhonor-std help any?


No, it didn't. Now gcc doesn't know the std::* classes anymore. The C++ headers of this version don't seem to specify any sort of namespace, so it's not really surprising.

Anyway, I've got the patch done. There already was a vec2d, so I just made this one a vec3d. Where am I supposed t'post it?

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Er, proper C++ would be to have the std:: definition with the declarations of the vectors.

Which it is.
-C

 

Offline fizz

  • 25
    • Crimson Fields
Quote
Originally posted by WMCoolmon
Er, proper C++ would be t'have th'std:: definition with th'declarations o' th'vectors.

Which it is.


Erm, should've said "of this version of gcc", shouldn't I?

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Aye, matey.

Thu std labels ye seek shoud be found in tha' headuh files. If th' version o' GCC ye be usin' hath no recognizin' ability for th' valid C++, it seems a bit hackish t' be convertin' it to somethin' else.

If ye be dead set on rippin' out th' code and puttin' in another, I be content with th' name o' "vec".
-C

 

Offline StratComm

  • The POFressor
  • 212
  • Cameron Crazy
    • http://www.geocities.com/cek_83/index.html
I was going to suggest "fsvector" for the hack.  Not like I'm actually working on the code though.
who needs a signature? ;)
It's not much of an excuse for a website, but my stuff can be found here

"Holding the last thread on a page comes with an inherent danger, especially when you are edit-happy with your posts.  For you can easily continue editing in points without ever noticing that someone else could have refuted them." ~Me, on my posting behavior

Last edited by StratComm on 08-23-2027 at 08:34 PM

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
I plan on workin' on this (the gcc 2.95 issue) today.  I consider it a pain in th'butt t'change th'name o' th'vector struct so it's a last resort.  Changin' it t'vec though means that we would have t'probably change it in th'matrix struct too an' that's rather bothersome.  I'll play with it an' see an I can't find a less abrasive fix.

 

Offline fizz

  • 25
    • Crimson Fields
Quote
Originally posted by WMCoolmon
Thu std labels ye seek shoud be found in tha' headuh files. If th' version o' GCC ye be usin' hath nay recognizin' ability for th' valid C++, it seems a bit hackish t' be convertin' it t'somethin' else.


Yes, that behaviour be certainly not completely standards-compliant, but it's not like th'patch would make th'code less C++-y.

Quote
Originally posted by taylor
I plan on workin' on this (the gcc 2.95 issue) today.  I consider it a pain in th'stern t'change th'name o' th'vector struct so it's a last resort.  Changin' it t'vec though means that we would have t'probably change it in th'matrix struct too an' that's rather bothersome.  I'll play with it an' see an I can't find a less abrasive fix.


As mentioned, I did th'patch with "vec3d" now but as that's a tad more unique than "vector" it should just be a matter o' find an' replace t'use somethin' else. Now, do ye want me t'post th'patch somewhere, or are ye goin' t'redo it yourself?

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Quote
Originally posted by fizz
As mentioned, I did th'patch with "vec3d" now but as that's a tad more unique than "vector" it should just be a matter o' find an' replace t'use somethin' else. Now, do ye want me t'post th'patch somewhere, or are ye goin' t'redo it yourself?

"vec3d", sorry didn't look that close.  I do want t'find a way t'get it workin' without havin' t'use th'patch but hie ahead an' post it so that I'll have it just in case.  If ye don't have a place t'stick it for download then just e-mail it t'me.

 

Offline fizz

  • 25
    • Crimson Fields

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Vector->vec3d has now been fixed in the original FRED.

  

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Quote
Originally posted by Goober5000
Vector->vec3d has now been fixed in the original FRED.

Ehh, forgot to check FRED.  Sorry.