View Issue Details

IDProjectCategoryView StatusLast Update
0002747AIAIpublic2011-12-14 10:02
ReporterAF Assigned Tohoijui  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
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.

Activities

hoijui

2011-11-23 21:10

reporter   ~0007660

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

AF

2011-12-11 19:53

reporter   ~0007858

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

AF

2011-12-11 23:40

reporter   ~0007861

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

hoijui

2011-12-12 18:14

reporter   ~0007865

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.

AF

2011-12-12 18:21

reporter   ~0007866

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 )

AF

2011-12-13 00:33

reporter   ~0007873

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 )

AF

2011-12-13 00:33

reporter   ~0007874

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

AF

2011-12-13 00:47

reporter   ~0007876

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

AF

2011-12-13 00:49

reporter   ~0007877

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

AF

2011-12-13 02:15

reporter   ~0007879

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.

Kloot

2011-12-13 03:10

developer   ~0007880

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.

hoijui

2011-12-13 10:17

reporter   ~0007886

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. :-)

AF

2011-12-13 11:11

reporter   ~0007887

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

hoijui

2011-12-13 16:52

reporter   ~0007890

did both changes:

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

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

AF

2011-12-14 00:47

reporter   ~0007894

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

AF

2011-12-14 00:50

reporter   ~0007895

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.

AF

2011-12-14 00:55

reporter   ~0007896

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

AF

2011-12-14 01:08

reporter   ~0007897

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

Kloot

2011-12-14 01:11

developer   ~0007898

are those sources compiled in C90 or in C99 mode?

AF

2011-12-14 02:00

reporter   ~0007901

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

AF

2011-12-14 02:02

reporter   ~0007902

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

abma

2011-12-14 08:59

administrator   ~0007903

@AF: did you try with hoijui recent changes?

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

you write like you didn't test that

hoijui

2011-12-14 09:28

reporter   ~0007904

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

hoijui

2011-12-14 09:33

reporter   ~0007905

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?

abma

2011-12-14 10:02

administrator   ~0007906

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

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