Coding Guidelines question: C++ syntax conflicts

Hi folks! :slight_smile:

My latest patch for Terminal has failed to build on x86_gcc2, I believe because of my use of an array initializer in a constructor that was introduced in (I think) C++11. I’m happy to fix this of course (and will be adding x86_gcc2 to my testing workflow). I don’t think there is a compatible initializer syntax for both C++ standards (?) so expect I should just initialize in the body of the constructor unless review has a better suggestion.

But I noticed that the Haiku Coding Guidelines doesn’t mention the case where an outright conflicting syntax might exist for the compiler versions, and the preferred resolution for that. So I figured I’d bring the question here. Is there a generally applicable approach that is preferred? For example: “Always use syntax that is compatible with C++98”, or maybe instead “Sometimes it is required to use obsolete syntax for x86_gcc2, handle this on a case-by-case basis”? Does this occur enough for a statement/example to be worth adding to the guidelines?

cc: @phoudoin

2 Likes

If the code needs to be buildable for gcc2 then only use compatible syntax. This is normally only the case for Kernel code and userspace libraries. I’m not sure why Terminal would be build on the gcc2 arch… maybe it can be removed to only build on modern gcc

Kernel isn’t built with gcc2 anymore.

1 Like

I guess only code exposing API that should be binary compatible with BeOS gcc2 must still compile with gcc2.

For apps like Terminal, it make no point indeed.

1 Like

Which lead to next question: how to make all jam targets builds with latest GCC except for explicit targets requiring to be ABI compatible when building Haiku for gcc2h ?

This is a bit of a sledgehammer solution IMO.

Here is @trungnt2910 proposal to use LLVM instead of GCC2, the main problem with syntax and compilation is the use of the obsolete GCC2:

This is not relevant here… please don’t start with your link spam again

Terminal actually has a replicant mode. So it needs to be built with GCC2 for that to work properly on the primary arch, at least.

1 Like

You’re right!
I forgot about replicants.

So @AutumnMeowMeow , no choice here, the code has to compile under gcc2 too.