Programming Question Defining type "int" in C++ file

Columbia42

Member
Joined
Dec 4, 2009
Messages
884
Reaction score
0
Points
16
Location
C:\ProgramFiles\Orbiter
I am trying to compile some code (it's not mine, I just made some minor changes) but even when I delete my changes I get errors that say "Missing type specifier - int assumed. Note: C++ does not support default-int" (The build log is here: http://pastebin.com/mP305F0T) The problem is, when I specify the section as type "int" it says "type int unexpected" and won't build the project. I'm using VC++ 2008 and the code I am trying to compile is Igel's V2 source code. ([ame="http://www.orbithangar.com/searchid.php?ID=2647"]V2 by igel[/ame])
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,621
Reaction score
2,341
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
That error comes when you forget a type specification.
 

Columbia42

Member
Joined
Dec 4, 2009
Messages
884
Reaction score
0
Points
16
Location
C:\ProgramFiles\Orbiter
Well I'm not the one who wrote the code and since Igel's V2 addon works, perhaps a previous version of the source code was included with it. Also, when I define the type int like the build log said to do, it says "type int unexpected."
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
I just downloaded this add-on to check that.

You mean these 2 lines?:
PHP:
const TIME_VERT = 4;		// vertical takeoff, sec
const RANGE_LOSS_IDEAL = 6100;   // %%% f(range)? calibrate on EQU!    // empirical range loss on air drag


When I changed them to "const int", the code compiled fine for me without any error or warning:
PHP:
const int TIME_VERT = 4;		// vertical takeoff, sec
const int RANGE_LOSS_IDEAL = 6100;   // %%% f(range)? calibrate on EQU!    // empirical range loss on air drag

I haven't tested it in Orbiter, though.
 

cjp

Addon Developer
Addon Developer
Donator
Joined
Feb 7, 2008
Messages
856
Reaction score
0
Points
0
Location
West coast of Eurasia
I followed the first complaint of the compiler, and had a look at line 15 of the file V2i.h.

Code:
const VECTOR3 OFS           = {0, 0, 0}; // universal mesh offset 
const TIME_VERT = 4;        // vertical takeoff, sec 
const RANGE_LOSS_IDEAL = 6100;   // %%% f(range)? calibrate on EQU!    // empirical range loss on air drag
I'd fix it this way:
Code:
const VECTOR3 OFS           = {0, 0, 0}; // universal mesh offset 
const int TIME_VERT = 4;        // vertical takeoff, sec 
const int RANGE_LOSS_IDEAL = 6100;   // %%% f(range)? calibrate on EQU!     // empirical range loss on air drag
Apparently, igel's compiler accepted the first form, but your (probably newer) compiler doesn't. I don't know if you have experience in C-like languages (C, C++, Java), but I think you can fix the same errors by applying the same change to the other lines.

The last error is different. I think it can be fixed by substituting line 1656 of v2i.cpp with this:
Code:
    srand((unsigned int)time(NULL));
 

Columbia42

Member
Joined
Dec 4, 2009
Messages
884
Reaction score
0
Points
16
Location
C:\ProgramFiles\Orbiter
I just downloaded this add-on to check that.

You mean these 2 lines?:
PHP:
const TIME_VERT = 4;        // vertical takeoff, sec
const RANGE_LOSS_IDEAL = 6100;   // %%% f(range)? calibrate on EQU!    // empirical range loss on air drag


When I changed them to "const int", the code compiled fine for me without any error or warning:
PHP:
const int TIME_VERT = 4;        // vertical takeoff, sec
const int RANGE_LOSS_IDEAL = 6100;   // %%% f(range)? calibrate on EQU!    // empirical range loss on air drag

I haven't tested it in Orbiter, though.


That also worked for me in the header file however it doesn't work in the .cpp file.

---------- Post added at 09:01 PM ---------- Previous post was at 08:52 PM ----------

For some reason it works for me now. I think because I needed to fix the header file first (previously I had tried to fix the .cpp file first.)

---------- Post added at 09:59 PM ---------- Previous post was at 09:01 PM ----------

Just tried the module in Orbiter with the modified code. Orbiter crashed as soon as I applied thrust.
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
Just tried the module in Orbiter with the modified code. Orbiter crashed as soon as I applied thrust.

Run the Orbiter from within VC++ with the module compiled in debug mode. Debugger will stop on the line where the exception is occurring, and you can check what is causing it, and eventually fix it.
 
Top