2025-07-04 11:02 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002747AIAIpublic2011-12-14 10:02
ReporterAF 
Assigned Tohoijui 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
Summary0002747: VS2010 AI calling convention declaration compile error
Descriptionai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2443): error C2143: syntax error : missing ';' before 'type'
ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2445): error C2065: '_ret' : undeclared identifier
ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2454): error C2143: syntax error : missing ';' before 'type'
ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2456): error C2065: '_ret' : undeclared identifier
ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2465): error C2143: syntax error : missing ';' before 'type'
ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2467): error C2065: '_ret' : undeclared identifier
ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2468): error C2065: '_ret' : undeclared identifier

etc etc etc
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0007660

hoijui (reporter)

i don't understand the problem here. :/
can you explain it?
there is no 'type' in that line...

~0007858

AF (reporter)

EXPORT(int) bridged__Cheats_setMyIncomeMultiplier(int skirmishAIId, float factor) {

    struct SSetMyIncomeMultiplierCheatCommand commandData;
    commandData.factor = factor;

    int _ret = id_clb[skirmishAIId]->Engine_handleCommand(skirmishAIId, COMMAND_TO_ID_ENGINE, -1, COMMAND_CHEATS_SET_MY_INCOME_MULTIPLIER, &commandData);

    return _ret;
}

It is the line int _ret that the compiler reports as being the issue, although I suspect it has more to do with the EXPORT macro, but I cannot speculate as to why

~0007861

AF (reporter)

EXPORT expands to:

SHARED_EXPORT type CALLING_CONV

thus:

EXTERNALIZER __declspec(dllexport) type CALLING_CONV
extern "C" __declspec(dllexport) type CALLING_CONV
extern "C" __declspec(dllexport) type SPRING_CALLING_CONVENTION_2
extern "C" __declspec(dllexport) type __stdcall

~0007865

hoijui (reporter)

ahhh. now that i call info!
could you possibly pastebin the whole output?

i assume that VS either does not like "EXPORT" or "type".
most likely, it defines EXPORT itsself, and thus expands "EXPORT(int)" to "<something>(type)" and then fails.
one thing we could try, is to put an "#ifdef EXPORT\n#undef EXPORT\n#endif" into rts/System/exportdefines.h, before we define the EXPORT macro there.
maybe you could do that yourself, to test if it works, and report back?
renaming this macro would be very ugly, as it is used by all native AI stuff, the C API and unitsync.

~0007866

AF (reporter)

I'll try, the output error log complained with the same 3 errors over and over again then cancelled itself at 100 errors. I'll try the macro definition you mentioned, though I won't have time till tomorrow evening ( plans later this evening after work )

~0007873

AF (reporter)

Here's the output of a "build solution" immediately after a clean:

http://pastebin.com/69fuaJLj

Note my spring source folder is not version 0.82.6.1, I just gutted the folder when 0.83 came out and repeated the process every time a newer version came out ( I know, more work for me )

~0007874

AF (reporter)

The errors are at the end, prior to that file all compiles although various warnings are given about assignment operator generation etc

~0007876

AF (reporter)

Also of note, I expanded the preprocessor statement manually resulting in:

line 2438:

extern "C" __declspec(dllexport) int CALLING_CONV bridged__Cheats_setMyIncomeMultiplier(int skirmishAIId, float factor) {

    struct SSetMyIncomeMultiplierCheatCommand commandData;
    commandData.factor = factor;

    int _ret = id_clb[skirmishAIId]->Engine_handleCommand(skirmishAIId, COMMAND_TO_ID_ENGINE, -1, COMMAND_CHEATS_SET_MY_INCOME_MULTIPLIER, &commandData);

    return _ret;
}

This changed the error to:


1> CombinedCallbackBridge.c
1>d:\media\documents\development\spring_0.82.6.1\ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2438): error C2059: syntax error : 'string'
1>d:\media\documents\development\spring_0.82.6.1\ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2454): error C2143: syntax error : missing ';' before 'type'
1>d:\media\documents\development\spring_0.82.6.1\ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2456): error C2065: '_ret' : undeclared identifier
1>d:\media\documents\development\spring_0.82.6.1\ai\wrappers\cpp\src-generated\combinedcallbackbridge.c(2465): error C2143: syntax error : missing ';' before 'type'

The extern "C" is strongly suspect

~0007877

AF (reporter)

I tested the extern theory by changing exportdefines.h to define EXTERNALIZER as nothing regardless of wether cplusplus is defined, with the following result:

http://pastebin.com/awLRea8q

conclusion, unlikely to be the extern

~0007879

AF (reporter)

If I change the first function it complains about to:

EXPORT(int) bridged__Cheats_setMyIncomeMultiplier(int skirmishAIId, float factor) {

    struct SSetMyIncomeMultiplierCheatCommand commandData;
    commandData.factor = factor;

    return id_clb[skirmishAIId]->Engine_handleCommand(skirmishAIId, COMMAND_TO_ID_ENGINE, -1, COMMAND_CHEATS_SET_MY_INCOME_MULTIPLIER, &commandData);
}

and attempt to build that file, the first error reported is now in the function immediately below. All changes to export defines header were undone prior to this test.

~0007880

Kloot (developer)

Last edited: 2011-12-13 03:13

possibly VS2010 doesn't like variables starting with a '_'? although that would be a regression, http://msdn.microsoft.com/en-us/library/565w213d.aspx says they are allowed. note also the remark about "Double underscores (_ _) forbidden anywhere" which are in all the generated API function names.

~0007886

hoijui (reporter)

following your testing results, AF, i my guess is similar to the one of Kloot.
try renaming _ret to my_ret or so.
i guess it would be better to unuse the double underscores, but it most likely is not the problem here, as it works for most functions (while all have them).

i will rename the _ret var, and maybe also remove the __ everywhere (depending on how much it breaks/how ugly the change is).
thanks Kloot. :-)

~0007887

AF (reporter)

According to this:

http://msdn.microsoft.com/en-us/library/565w213d.aspx

You can have a single underscore as the starting character of an identifier, but not double underscore. You can however have a $ sign =p

~0007890

hoijui (reporter)

did both changes:

"__ -> _"
https://github.com/spring/spring/commit/3695b52e2f994aca717a3b3d60ed9f7ab50bef7c

"_ret -> internal_ret"
https://github.com/spring/spring/commit/0ace4d37955c12a4a59dd05c299a7e1b9dd649d5

~0007894

AF (reporter)

Before I did anything else I renamed _ret in the first error to mret, no change

~0007895

AF (reporter)

also of note, I removed the EXPORT(int) macro and replaced it with just int and saw no improvement, so the macro is very unlikely to be related.

The only clue so far is that assigning the return value to an integer and returning it doesn't compile but returning the value directly does.

~0007896

AF (reporter)

If I declare:

int _ret=0;

at the top of the file, and remove replace 'int _ret' with '_ret' said function compiles and an error is removed, if I were to systematically go through eveyr single one I could eradicate most of them.

Granted the method of doing so seems kludgey

~0007897

AF (reporter)

A search replace in that file of int _ret = id to _ret = id with aforementioned change, resulted in that file compiling

~0007898

Kloot (developer)

are those sources compiled in C90 or in C99 mode?

~0007901

AF (reporter)

I have no idea, there is no option for either in the project setup, I'm not sure Visual studio even distinguishes between C90 and C99 mode, it either supports a feature or it doesn't, and it provides means of using compilers from past Visual studios as backwards compatibility if things break moving to VS2010.

Of note, this is the last issue preventing Shard compiling, if I try a full build with the above amendments the build succeeds and proceeds to the linker stage

~0007902

AF (reporter)

http://stackoverflow.com/questions/146381/visual-studio-support-for-new-c-c-standards

~0007903

abma (administrator)

@AF: did you try with hoijui recent changes?

"__ -> _"
"_ret -> internal_ret"

you write like you didn't test that

~0007904

hoijui (reporter)

he did test it (though he made the change himself), and it did not help.
no VS version up to now supports C99, and .. guess that is not likely to change ;-)
but yeah.. good we know the problem now, so i can fix it, even though it will make the AWK files just a little more ugly... that does not make a huge different in the end. :D
.. i would have though that even C90 supports declaring vars through tough the function though. especially cause.. i never cared for that, and i wrote a lot of C code for spring, and i can't imagine it all follows that rule...
maybe C code within .cpp files supports more "advanced" stuff the C code in .c files when compiling with VS?

fazzit: VS sucks even just a little more then we though :D

~0007905

hoijui (reporter)

that link AF posted. hillarious! :D
VS dev about C99 features:
"we’ve tried to implement them (or analogues)"
.. after all, its just poor little Microsoft, and it is only 12 years now since 99, so... don't push it!

the other excuse mentioned:
"unfortunately the overwhelming feadback we get from the majority of our users is that they would prefer that we focus on C++-0x instead of on C-99"
... i kinda would guess, that code using 0x features would probably also use C99 features?

seriously, who they think they talking with? the mummies of C++ devs? people that think C++ is an iPhone app?

~0007906

abma (administrator)

https://github.com/spring/spring/commit/6906df925e4016acd4bfb11f5b9a035ed5a6a728
+Notes

-Issue History
Date Modified Username Field Change
2011-11-22 22:50 AF New Issue
2011-11-23 11:04 hoijui Severity block => major
2011-11-23 11:04 hoijui Status new => assigned
2011-11-23 11:04 hoijui Assigned To => hoijui
2011-11-23 21:10 hoijui Note Added: 0007660
2011-12-05 19:49 hoijui Status assigned => feedback
2011-12-11 19:53 AF Note Added: 0007858
2011-12-11 23:40 AF Note Added: 0007861
2011-12-12 18:14 hoijui Note Added: 0007865
2011-12-12 18:21 AF Note Added: 0007866
2011-12-13 00:33 AF Note Added: 0007873
2011-12-13 00:33 AF Note Added: 0007874
2011-12-13 00:47 AF Note Added: 0007876
2011-12-13 00:49 AF Note Added: 0007877
2011-12-13 02:15 AF Note Added: 0007879
2011-12-13 03:10 Kloot Note Added: 0007880
2011-12-13 03:13 Kloot Note Edited: 0007880
2011-12-13 03:13 Kloot Note Edited: 0007880
2011-12-13 10:17 hoijui Note Added: 0007886
2011-12-13 11:11 AF Note Added: 0007887
2011-12-13 16:52 hoijui Note Added: 0007890
2011-12-14 00:47 AF Note Added: 0007894
2011-12-14 00:50 AF Note Added: 0007895
2011-12-14 00:55 AF Note Added: 0007896
2011-12-14 01:08 AF Note Added: 0007897
2011-12-14 01:11 Kloot Note Added: 0007898
2011-12-14 02:00 AF Note Added: 0007901
2011-12-14 02:02 AF Note Added: 0007902
2011-12-14 08:59 abma Note Added: 0007903
2011-12-14 09:28 hoijui Note Added: 0007904
2011-12-14 09:33 hoijui Note Added: 0007905
2011-12-14 10:02 abma Note Added: 0007906
2011-12-14 10:02 abma Status feedback => resolved
2011-12-14 10:02 abma Resolution open => fixed
+Issue History