Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » The -pedantic compiler flag.

This thread is locked; no one can reply to it. rss feed Print
The -pedantic compiler flag.
AMCerasoli
Member #11,955
May 2010
avatar

Man I couldn't stop laughing when I activated the -pedantic flag in MinGW and it gave me an error in the Allegro library, and I was like uh? what could it be? And when I saw the error...

typedef enum ALLEGRO_FILE_MODE
{
   ALLEGRO_FILEMODE_READ    = 1,
   ALLEGRO_FILEMODE_WRITE   = 1 << 1,
   ALLEGRO_FILEMODE_EXECUTE = 1 << 2,
   ALLEGRO_FILEMODE_HIDDEN  = 1 << 3,
   ALLEGRO_FILEMODE_ISFILE  = 1 << 4,
   ALLEGRO_FILEMODE_ISDIR   = 1 << 5, // < -- This?... My god...
} ALLEGRO_FILE_MODE;

4.6.2\include\allegro5\fshook.h|52|error: comma at end of enumerator list [-pedantic]|

Hahahahaha ::) Why the compiler is so strict sometimes and sometimes is not?

Thomas Fjellstrom
Member #476
June 2000
avatar

-pedantic really means what it says it means. It's there to be pedantic. Now add -ansi to the argument list and see how much it screams.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

AMCerasoli
Member #11,955
May 2010
avatar

Uh? it didn't gave me any errors with -ansi :-/ are you pulling my leg?

Thomas Fjellstrom
Member #476
June 2000
avatar

Uh? it didn't gave me any errors with -ansi are you pulling my leg?

That probably just means we've done a decent job with Allegro :o

-ansi and -pedantic together usually lead to a lot of warnings and errors for projects. You are adding -Wall -Wextra right?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

AMCerasoli
Member #11,955
May 2010
avatar

You are adding -Wall -Wextra right?

No I had only -Wall, I have just added -Wextra but it's the same. Man why my compiler doesn't give me any errors? I want compilers errors. ;D

When I made the trivia game I didn't use none of this, and even not using them I had some warnings about variables being initialized first in the initialization list and problems with char and int being compared, but this time I want to let it everything crystal clear, since the project is going to be a lot bigger.

My next videogame...

Emancipation: A World Without Peace

video

Yay \o/

Thomas Fjellstrom
Member #476
June 2000
avatar

No I had only -Wall, I have just added -Wextra but it's the same. Man why my compiler doesn't give me any errors? I want compilers errors.

Write worse code.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Peter Wang
Member #23
April 2000

Fixed, thanks.

AMCerasoli
Member #11,955
May 2010
avatar

Well I just put it here to let you know... There is another comma out there! be careful you can blow out your PC!

enum ALLEGRO_MIXER_QUALITY
{
   ALLEGRO_MIXER_QUALITY_POINT   = 0x110,
   ALLEGRO_MIXER_QUALITY_LINEAR  = 0x111,
};

Allegro_audio.h

I'm finding this while including the headers in my project... hoHOho.

Arthur Kalliokoski
Second in Command
February 2005
avatar

From the zlib FAQ (q 35)

"Q: I get this or that compiler or source-code scanner warning when I crank it up to maximally-pedantic. Can't you guys write proper code?

A: Many years ago, we gave up attempting to avoid warnings on every compiler in the universe. It just got to be a waste of time, and some compilers were downright silly. So now, we simply make sure that the code always works."

They all watch too much MSNBC... they get ideas.

AMCerasoli
Member #11,955
May 2010
avatar

They can say whatever they want, but if I find another comma out of place I will stop using Allegro, and that is my last word... ;D

#SelectExpand
1//Arthurs Kalliokoski's code 2 3#include <lol.h> 4 5int main(){ 6 enum Arthur_pepsi_packs{ 7 MONDAY = 1000, 8 TUESDAY = 500, 9 WEDNESDAY = 000, 10 THURSDAY = 1000, 11 FRIDAY = 1500, 12 SATURDAY = 500, 13 SUNDAY = 000, 14 , 15 , 16 } 17 18 return 0;;;;;;;;;;;;;;;;; 19}

Arthur Kalliokoski
Second in Command
February 2005
avatar

There should be a for(;;) loop in there somewhere, and Wednesday's and Sunday's values are totally unacceptable. >:(

They all watch too much MSNBC... they get ideas.

Peter Wang
Member #23
April 2000

if I find another comma out of place I will stop using Allegro

There were two more.

Anyway, it's worth fixing these things in public headers because you never know where they will be included.

Bruce Perry
Member #270
April 2000

For consistency you need to keep all the numbers the same length:

#SelectExpand
1//Arthurs Kalliokoski's code 2 3#include <lol.h> 4 5int main(){ 6 enum Arthur_pepsi_packs{ 7 MONDAY = 1000, 8 TUESDAY = 0500, 9 WEDNESDAY = 0000, 10 THURSDAY = 1000, 11 FRIDAY = 1500, 12 SATURDAY = 0500, 13 SUNDAY = 0000, 14 , 15 , 16 } 17 18 return 0;;;;;;;;;;;;;;;;; 19}

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

Arthur Kalliokoski
Second in Command
February 2005
avatar

Are you forgetting that starting a number with a zero (but no x) means the compiler interprets it as octal?

They all watch too much MSNBC... they get ideas.

Bruce Perry
Member #270
April 2000

No, that's exactly why I 'corrected' the code :)

--
Bruce "entheh" Perry [ Web site | DUMB | Set Up Us The Bomb !!! | Balls ]
Programming should be fun. That's why I hate C and C++.
The brxybrytl has you.

Go to: