CVS version compiling error
Moderator: Forum Moderators
Forum rules
Before reporting issues in this section, you must read the following topic:
Before reporting issues in this section, you must read the following topic:
CVS version compiling error
Code: Select all
g++ -O2 -Wall -I. -Isrc -Isrc/tools -Isrc/widgets `sdl-config --cflags` `freetype-config --cflags` -c src/playturn.cpp -o src/playturn.o
src/playturn.cpp: In function `void play_turn (game_data &, game_state
&, gamestatus &, config &, config *, CVideo &, CKey &, display &,
game_events::manager &, gamemap &, vector<team, allocator<team> > &,
int, map<gamemap::location, unit, less<gamemap::location>,
allocator<unit> > &)':
src/playturn.cpp:241: `round' undeclared (first use this function)
src/playturn.cpp:241: (Each undeclared identifier is reported only once
for each function it appears in.)
make: *** [src/playturn.o] Error 1
I tried changing it to include math.h (is this the same as cmath?), but got the same error. So instead I removed the calls to round then it complied okay
0.4.8 (which compiled fine) playturn.cpp uses ceil() 4 times. <cmath> is included at the top which defines this function.
I ran a grep and ceil() *is* defined in my cmath file but the *only* reference to round() is in tgmath.h which I don't know what is. Maybe my development environment is incomplete.....?
- 232: << int(ceil(100.0*stats.chance_to_hit_defender)) << "%";
238: << int(ceil(100.0*stats.chance_to_hit_attacker)) << "%";
682: const int resist=int(100.0-ceil(100.0*resistance));
722: const int def = int(100.0-ceil(100.0*defense));
- 241: << int(round(100.0*stats.chance_to_hit_defender))<< "%";
247: << int(round(100.0*stats.chance_to_hit_attacker))<< "%";
699: const int resist = 100 - int(round(100.0*resistance));
744: const int def = 100-int(round(100.0*defense));
I ran a grep and ceil() *is* defined in my cmath file but the *only* reference to round() is in tgmath.h which I don't know what is. Maybe my development environment is incomplete.....?
The problem is that round() is only C99 standard, not C89 or C++98 standard, and so not included on some compilers. (Although the C99 standard is what? 4 whole years old now! You'd think most compilers would support it by now)
I have fixed the problem in CVS simply by defining our own version of round().
David
I have fixed the problem in CVS simply by defining our own version of round().
David