|
C++ Error: void value not ignored as it ought to be |
northdakota91
Member #10,342
October 2008
|
Hi to all, I get this error when I try to compile a source: [CODE] Object.h: In member function `void Object::load_bitmap(const char*, bool)': make.exe: *** [main.o] Error 1 [CODE] and this: [CODE] I get an error when I try to use load_bitmap(). The class is this one: Why i get that error? |
monkeyCode
Member #7,140
April 2006
|
unsigned frames; Other than that: fix the code tags and I'll actually read the code |
northdakota91
Member #10,342
October 2008
|
I've found the error! I've called a class method with an allegro function name (load_bitmap()). Sorry, that was my stupid fault... Anyway, what's the tag to post the code? (sorry if I'm out of topic ) |
monkeyCode
Member #7,140
April 2006
|
Another thing. if (state) { result = true; } else { result = false; } // That's way to redundant, use assignments! :-) result = state; result = !state; // inverse. Also // GCC does default to int, can't remember if it's a part of the specification or just a GCC niche (I'm in the C# world now days) // Anyways, even from just a readability standpoint, unsigned int is so much clearer. unsigned value;
|
Speedo
Member #9,783
May 2008
|
Quote: // GCC does default to int, can't remember if it's a part of the specification or just a GCC niche C uses default-int, C++ doesn't. |
Tobias Dammers
Member #2,604
August 2002
|
http://www.cppreference.com/wiki/data_types said: Several of these types can be modified using the keywords signed, unsigned, short, and long. When one of these type modifiers is used by itself, a data type of int is assumed. Using unsigned by itself is perfectly OK. --- |
bamccaig
Member #7,536
July 2006
|
Tobias Dammers said: Using unsigned by itself is perfectly syntactically correct. Fixed. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Tobias Dammers
Member #2,604
August 2002
|
It is syntactically correct yes, which means it is the shortest way of specifying an unsigned int. Since the 'int' keyword is optional, and everyone with some semi-decent knowledge of C++ knows that it's implicit, I don't see why one needs to add it. Just like you don't write 'signed short int' but rather just 'short', or 'long' instead of 'signed long int'. I consider it good practice to not clobber the code with stuff that doesn't carry any added information. --- |
|