Difficulties with my little C++ .dll

I am editing one of my meshes in c++ form because of the benefits that it has to offer. However it is not that easy. I am kind of stuck. Here is my error and here is my .cpp.

1>.\AtlasA.cpp(53) : error C2143: syntax error : missing ';' before '}'
1>.\AtlasA.cpp(55) : error C2447: '{' : missing function header (old-style formal list?)
1>.\AtlasA.cpp(107) : fatal error C1004: unexpected end-of-file found

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// JD Rocket.cpp : Defines the exported functions for the DLL application.
//

#define ORBITER_MODULE
#include "orbitersdk.h"
#include "OrbiterAPI.h"
#include "orbitersdk.h" 
 
HINSTANCE g_hDLL; 
 
DLLCLBK void InitModule (HINSTANCE hModule) 
{ 
    g_hDLL = hModule; 
    // perform global module initialisation here 
} 


class AtlasA: public VESSEL2 {
public:
	AtlasA (OBJHANDLE hVessel, int flightmodel)
		: VESSEL2 (hVessel, flightmodel) {}
	void clbkSetClassCaps (FILEHANDLE cfg);
};
class MyVessel: public VESSEL2 {
public:
MyVessel (OBJHANDLE hObj, int fmodel): VESSEL2 (hObj, fmodel) {}
~MyVessel () {}
void clbkLoadStateEx (FILEHANDLE scn, void *status);
void clbkSaveState (FILEHANDLE scn);
private:
double myparam;
};
void MyVessel::clbkLoadStateEx (FILEHANDLE scn, void *status)
{
char *line;
while (oapiReadScenario_nextline (scn, line)) {
if (!_strnicmp (line, "MYPARAM", 7)) {
	sscanf (line+7, "%lf", &myparam);
} else {
ParseScenarioLineEx (line, status);
}
}
}
void MyVessel::clbkSaveState (FILEHANDLE scn)
{
VESSEL2::clbkSaveState (scn);
oapiWriteScenario_float (scn, "MYPARAM", myparam);
}

void AtlasA::clbkSetClassCaps (FILEHANDLE cfg)
{
	THRUSTER_HANDLE th_main, th_hover, th_rcs[14], th_group[4];
}
//
{
	SetSize (22.9);
	SetEmptyMass (150000.0);
	SetCW (0.3, 0.3, 0.6, 0.9);
	SetWingAspect (0.7);
	SetWingEffectiveness (2.5);
	SetCrossSections (_V(51.34,58.45,6.73));
	SetRotDrag (_V(0.6,0.6,0.35));
	if (GetFlightModel() >= 1) {
		SetPitchMomentScale (1e-4);
	}
	SetPMI (_V(78.8,79.81,2.08));
	SetTrimScale (0.05);
	SetCameraOffset (_V(0,0.8,0));
	SetTouchdownPoints (_V(0,-1.5,2), _V(-1,-1.5,-1.5), _V(1,-1.5,-1.5));

	
	PARTICLESTREAMSPEC contrail_main = {
		0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};
	PARTICLESTREAMSPEC contrail_hover = {
		0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};
	PARTICLESTREAMSPEC exhaust_main = {
		0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	PARTICLESTREAMSPEC exhaust_hover = {
		0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	AddMesh (oapiLoadMeshGlobal "AtlasA"));
	{

DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel);
{
	return new AtlasA (hvessel, flightmodel);
}

// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
DLLCLBK void ovcExit (VESSEL *vessel)

	if (vessel) delete (AtlasA*)vessel;
}



Thank you.
Your parentheses are are mostly inconsistent/incorrect. Your indentation doesn't help, it's supposed to help you see scope and where parentheses ought to be.
My parentheses or brackets?
Both, actually.
Apparently I am new at this, but I think I am making some progress. I got 2 errors.

.\AtlasA.cpp(35) : error C2470: 'line' : looks like a function definition, but there is no parameter list; skipping apparent body
1>.\AtlasA.cpp(104) : fatal error C1004: unexpected end-of-file found

Here is the new code.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// JD Rocket.cpp : Defines the exported functions for the DLL application.
//

#define ORBITER_MODULE
#include "orbitersdk.h"
#include "OrbiterAPI.h"
#include "orbitersdk.h" 
 
HINSTANCE g_hDLL; 
 
DLLCLBK void InitModule (HINSTANCE hModule) 
{ 
    g_hDLL = hModule; 
    // perform global module initialisation here 
} 


class AtlasA: public VESSEL2 {
public:
	AtlasA (OBJHANDLE hVessel, int flightmodel)
		: VESSEL2 (hVessel, flightmodel) {}
	void clbkSetClassCaps (FILEHANDLE cfg);
};
class MyVessel: public VESSEL2 {
public:
MyVessel (OBJHANDLE hObj, int fmodel): VESSEL2 (hObj, fmodel) {}
~MyVessel() {}
void clbkLoadStateEx (FILEHANDLE scn, void *status);
void clbkSaveState (FILEHANDLE scn);
private:
double myparam;
}

 ;char *line
 {
if (!_strnicmp (line, "MYPARAM", 7)) 
	;sscanf (line+7, "%lf", &myparam);
;{ else 
ParseScenarioLineEx (line, status);
}
void MyVessel::clbkSaveState (FILEHANDLE scn)
{
VESSEL2::clbkSaveState (scn);
oapiWriteScenario_float (scn, "MYPARAM", myparam);
}

void AtlasA::clbkSetClassCaps (FILEHANDLE cfg)
{
	THRUSTER_HANDLE th_main, th_hover, th_rcs[14], th_group[4];
	{
//
	}
	SetSize (22.9);
	SetEmptyMass (150000.0);
	SetCW (0.3, 0.3, 0.6, 0.9);
	SetWingAspect (0.7);
	SetWingEffectiveness (2.5);
	SetCrossSections (_V(51.34,58.45,6.73));
	SetRotDrag (_V(0.6,0.6,0.35));
	if (GetFlightModel() >= 1) {
		SetPitchMomentScale (1e-4);
	SetPMI (_V(78.8,79.81,2.08));
	SetTrimScale (0.05);
	SetCameraOffset (_V(0,0.8,0));
	SetTouchdownPoints (_V(0,-1.5,2), _V(-1,-1.5,-1.5), _V(1,-1.5,-1.5));
	}
	
	PARTICLESTREAMSPEC contrail_main = {
		0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};
	PARTICLESTREAMSPEC contrail_hover = {
		0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
		PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
	};
	PARTICLESTREAMSPEC exhaust_main = {
		0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	PARTICLESTREAMSPEC exhaust_hover = {
		0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
		PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
		PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
	};
	AddMesh (oapiLoadMeshGlobal "AtlasA");
	{
	}
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel);
{
	return new AtlasA (hvessel, flightmodel);
}

// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
{
DLLCLBK void ovcExit (VESSEL *vessel);

	if (vessel) delete (AtlasA*)vessel;
}
i think on line 34, it's missing the terminator ';' at the end of the line if line is not a function. Otherwise if line is a function, then it's missing its parentheses?
Thank you. I will try that and see what the result is.
Jesus Christ! This is a disaster!

I reformatted with AStyle. The comments describe syntactical problems.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#define ORBITER_MODULE
#include "orbitersdk.h"
#include "OrbiterAPI.h"
#include "orbitersdk.h"

HINSTANCE g_hDLL;

DLLCLBK void InitModule (HINSTANCE hModule){
    g_hDLL = hModule;
}


class AtlasA: public VESSEL2{
public:
    AtlasA (OBJHANDLE hVessel, int flightmodel)
        : VESSEL2 (hVessel, flightmodel) {}
    void clbkSetClassCaps (FILEHANDLE cfg);
};

class MyVessel: public VESSEL2{
public:
    MyVessel (OBJHANDLE hObj, int fmodel): VESSEL2 (hObj, fmodel) {}
    ~MyVessel() {}
    void clbkLoadStateEx (FILEHANDLE scn, void *status);
    void clbkSaveState (FILEHANDLE scn);
private:
    double myparam;
}

; // stray semicolon (illegal at global scope)
char *line { // is this a function?
    if (!_strnicmp (line, "MYPARAM", 7))
        ; // Stray semicolon. Makes if statement do nothing.
    sscanf (line+7, "%lf", &myparam); // this line runs unconditionally
    ; // stray semicolon
    { // Note: new block starts here...
        else // stray else
            ParseScenarioLineEx (line, status);
    } // ...and ends here. This line does NOT close the function.
    void MyVessel::clbkSaveState (FILEHANDLE scn){ // local function definitions are illegal
        VESSEL2::clbkSaveState (scn);
        oapiWriteScenario_float (scn, "MYPARAM", myparam);
    }

    void AtlasA::clbkSetClassCaps (FILEHANDLE cfg){ // local function definitions are illegal
        THRUSTER_HANDLE th_main, th_hover, th_rcs[14], th_group[4];
        { // ???
        }
        SetSize (22.9);
        SetEmptyMass (150000.0);
        SetCW (0.3, 0.3, 0.6, 0.9);
        SetWingAspect (0.7);
        SetWingEffectiveness (2.5);
        SetCrossSections (_V(51.34,58.45,6.73));
        SetRotDrag (_V(0.6,0.6,0.35));
        if (GetFlightModel() >= 1) {
            SetPitchMomentScale (1e-4);
            SetPMI (_V(78.8,79.81,2.08));
            SetTrimScale (0.05);
            SetCameraOffset (_V(0,0.8,0));
            SetTouchdownPoints (_V(0,-1.5,2), _V(-1,-1.5,-1.5), _V(1,-1.5,-1.5));
        }

        PARTICLESTREAMSPEC contrail_main = {
            0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
            PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
            PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
        };
        PARTICLESTREAMSPEC contrail_hover = {
            0, 5.0, 8, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
            PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
            PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
        };
        PARTICLESTREAMSPEC exhaust_main = {
            0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
            PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
            PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
        };
        PARTICLESTREAMSPEC exhaust_hover = {
            0, 2.0, 10, 200, 0.05, 0.05, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
            PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
            PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
        };
        AddMesh (oapiLoadMeshGlobal "AtlasA");
        { // ???
        }
        DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel); // Local local function definition? What?
        {
            return new AtlasA (hvessel, flightmodel);
        }

        {
            DLLCLBK void ovcExit (VESSEL *vessel);

            if (vessel) delete (AtlasA*)vessel;
        }
// one block still unclosed at end of file 
Last edited on
Sorry. I have barely any C++ experience. :/
Topic archived. No new replies allowed.