Skip to content

Commit

Permalink
Fixed compilation errors and warnings with GCC 4.7
Browse files Browse the repository at this point in the history
Also, since GCC 4.7 there is a binary compatibility issue when linking with a
Guichan that was not compiled in C++11 mode. This commit also allows compiling
with GCC 4.7 with C++11 mode turned off.

Reviewed-by: Erik Schilling
  • Loading branch information
bjorn committed May 5, 2012
1 parent c32c174 commit 8615417
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/cpp0x_compat/cstdint
@@ -1,7 +1,10 @@
/*
* Compatibility header used when the compiler doesn't support C++0x.
*
* It doesn't seem necessary for it to contain anything, at least GCC 4.2.1
* compiles Mana fine so it apparently understands types like uint16_t by
* default.
* While GCC 4.2.1 understands types like uint16_t by default, later versions
* are more strict so here are some typedefs for types used in our code.
*/

typedef unsigned char uint8_t;

This comment has been minimized.

Copy link
@Flameeyes

Flameeyes Jul 27, 2012

This sounds like a very very bad idea. GCC tends to make these workaround cause even more bugs in the following versions, so we'll likely end up revisiting this pretty soon.

If you don't want to go with C++11 all the way, maybe you want to try using #include <tr1/cstdint> (which as far as I can tell still allows using cstdint without having to go through the C++11 implementation).

This comment has been minimized.

Copy link
@bjorn

bjorn Jul 28, 2012

Author Member

Nope. you can't include cstdint with a recent gcc when compiling in non C++11 mode. If you have a better solution for this problem, I welcome your patch.

Basically, I know this is a hack, and I only did it to avoid having to rename all occurrences of these types in all of the source code. The code is meant to be compiled in C++11 mode, and this file is only meant to enable (temporarily) compiling it in non C++11 mode, for as long as there are still platforms that require this (like Maemo and unfortunately since GCC 4.7 also platforms which have a non C++11 compiled Guichan - I hope they'll fix that binary compatibility in future versions of GCC).

This comment has been minimized.

Copy link
@Ablu

Ablu Jul 28, 2012

Member

Sorry I do not really understand...
What shall we do instead now? How shall we "try using #include"?
EDIT: Too slow

This comment has been minimized.

Copy link
@mgorny

mgorny Jul 28, 2012

I have a patch ready, will rebase it and submit in the next few minutes.

typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
3 changes: 2 additions & 1 deletion src/gui/widgets/tabbedarea.h
Expand Up @@ -98,7 +98,8 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
int getContainerHeight() const
{ return mWidgetContainer->getHeight(); }

using gcn::TabbedArea::setSelectedTab;
void setSelectedTab(unsigned int index)
{ gcn::TabbedArea::setSelectedTab(index); }

void setSelectedTab(gcn::Tab *tab);

Expand Down
1 change: 1 addition & 0 deletions src/gui/widgets/textfield.h
Expand Up @@ -63,6 +63,7 @@ struct TextHistory {

class AutoCompleteLister {
public:
virtual ~AutoCompleteLister() {}
virtual void getAutoCompleteList(std::vector<std::string>&) const {}
};

Expand Down
1 change: 1 addition & 0 deletions src/net/download.h
Expand Up @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <cstdlib> // pulls in int64_t

This comment has been minimized.

Copy link
@mgorny

mgorny Jul 28, 2012

Are you aware that this is not true with most compilers that exist? Do gcc people actually have to hide every single declaration so you people stop using hacks like this?

This comment has been minimized.

Copy link
@Ablu

Ablu Jul 28, 2012

Member

so what do you suggest to do otherwise?

This comment has been minimized.

Copy link
@bjorn

bjorn Jul 28, 2012

Author Member

I'm not aware of that (though I'm aware it's bad to rely on this behavior). But I had a choice between relying on this or add typedef for int64_t to our cstdint compatibility file. I didn't know how to properly typedef an int64_t so that it would work in both 32 and 64 bit mode, hence I went with this solution. Again, if you have a better solution, your patch is welcome.

#include <cstdio>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion src/resources/itemdb.h
Expand Up @@ -78,7 +78,7 @@ class ItemDB
mLoaded(false)
{}

~ItemDB()
virtual ~ItemDB()
{}

/**
Expand Down

0 comments on commit 8615417

Please sign in to comment.