GCC 5 concerns

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Primis
Member
Member
Posts: 62
Joined: Fri May 14, 2010 3:46 pm
Libera.chat IRC: Primis
Location: New York, NY
Contact:

GCC 5 concerns

Post by Primis »

With the impending GCC update to a new number (5) I'm assuming this is gonna break a lot of things, and it's not something that I can see being an easy cross compile build. Am I the only one worrying about this?
"On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."
Image
SoulofDeity
Member
Member
Posts: 193
Joined: Wed Jan 11, 2012 6:10 pm

Re: GCC 5 concerns

Post by SoulofDeity »

Primis wrote:With the impending GCC update to a new number (5) I'm assuming this is gonna break a lot of things, and it's not something that I can see being an easy cross compile build. Am I the only one worrying about this?
I tried the beta version a while back. It doesn't break anything from what I can tell. I may be mistaken, but I believe I read somewhere that the changes being made were in the backend; switching the algorithms being used to speed up compilation.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: GCC 5 concerns

Post by sortie »

You forgot to actually correlate your beliefs with reality. Go to gcc.gnu.org and read the change list. It is just another 0.1 release in the 4.x series, except it carried a one. I'm very much looking forward to builtin overflow checks and has_include.
SoulofDeity
Member
Member
Posts: 193
Joined: Wed Jan 11, 2012 6:10 pm

Re: GCC 5 concerns

Post by SoulofDeity »

sortie wrote:You forgot to actually correlate your beliefs with reality. Go to gcc.gnu.org and read the change list. It is just another 0.1 release in the 4.x series, except it carried a one. I'm very much looking forward to builtin overflow checks and has_include.
Seems like my beliefs correlate pretty well with reality. Most of the changes on that list are improvements for optimization or adding new backends. The rest are mostly warnings, new command line options for existing functionality, or the addition of extensions.

Also, this made me laugh a little:
New preprocessor constructs, __has_include and __has_include_next, to test the availability of headers have been added.
This demonstrates a way to include the header <optional> only if it is available:

Code: Select all

    #ifdef __has_include
    #  if __has_include(<optional>)
    #    include <optional>
    #    define have_optional 1
    #  elif __has_include(<experimental/optional>)
    #    include <experimental/optional>
    #    define have_optional 1
    #    define experimental_optional
    #  else
    #    define have_optional 0
    #  endif
    #endif
If you're going to take it that far, why not just replace the preprocessor with bash or ruby or something. Something like:

Code: Select all

#error -*- !bash -*-
# if [ -f <optional> ]; then
#   source <optional>
#   export have_optional=1
# else if [ -f <experimental/<optional> ]; then
#   export have_optional=1
#   export experimental_optional
# else
#   export have_optional=0
# fi
I'm not saying you should intentionally break C, but if you really need to do something like this, why not just use a custom preprocessor?
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

Re: GCC 5 concerns

Post by Bender »

Because the standard also defines stuff about the preprocessor, and you probably want backward compatibility with the standard defined preprocessor so that your compiler is considered sane?
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: GCC 5 concerns

Post by sortie »

SoulofDeity wrote:I'm not saying you should intentionally break C, but if you really need to do something like this, why not just use a custom preprocessor?
Ahem.

Code: Select all

/* Awful, awful things makes this happen. */
#ifdef HAVE_STDFOO_H
#include <stdfoo.h>
#endif
It's not preferable, very commonly needed, and could be much cleaner if it had just been a compiler feature. Oh hey, that's __has_include.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: GCC 5 concerns

Post by Combuster »

And is one big invitation to make code unportable.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
SoulofDeity
Member
Member
Posts: 193
Joined: Wed Jan 11, 2012 6:10 pm

Re: GCC 5 concerns

Post by SoulofDeity »

Bender wrote:Because the standard also defines stuff about the preprocessor, and you probably want backward compatibility with the standard defined preprocessor so that your compiler is considered sane?
There still would be; the line "#error -*- !bash -*-" would normally throw an error if bash preprocessing wasn't supported. I just think it's humorous how we keep on adding extensions to the preprocessor without considering that it's a separate language altogether.

eg. consider the following

Code: Select all

# define valueof(x) x
# define str_helper(x) #x
# define str(x) str_helper(x)

# define x 1
# define y 2

// print x
# pragma message str(x)

// ld x, y
# undef x
# define x valueof(y)

// inc x
# if valueof(x) == 0
#   undef x
#   define x 1
# elif valueof(x) == 1
#...
# elif valueof(x) == 255
#   undef x
#   define x 0
# endif

// dec y
# if valueof(y) == 0
#   undef y
#   define y 255
# elif valueof(y) == 255
#...
# elif valueof(y) == 1
#   undef y
#   define y 0
# endif

// add x, y
# if valueof(y) != 0
#   include "inc_x.c"
#   include "dec_y.c"
#   include "add_x_y.c"
# endif
And so on. You could write entire programs with just the preprocessor alone, it'd just take time. Now, with the latest addition of __has_include, you even have modules and interfaces.
Post Reply