error when using "int32_t main (int32_t argc, char * argv[])"

Hi,

I’m trying to get the ‘test-suite’ running using clang as a cross compiler for XCore.

However I have hit the following problem:

clang++ -c llvm-test-suite/MultiSource/Applications/ALAC/decode/main.cpp --target=xcore
llvm-test-suite/MultiSource/Applications/ALAC/decode/main.cpp:72:1: error: ‘main’ must return ‘int’
int32_t main (int32_t argc, char * argv)
^
llvm-test-suite/MultiSource/Applications/ALAC/decode/main.cpp:72:9: error: first parameter of ‘main’ (argument count) must be of type ‘int’
int32_t main (int32_t argc, char * argv)
^
2 errors generated.

However, running without the " --target=xcore" and all is fine.

The simple solution for me is to change ‘int32_t’ to ‘int’ in the two problematic files’ main functions viz:
llvm-test-suite/MultiSource/Applications/ALAC/decode/main.cpp:int32_t main (int32_t argc, char * argv)
llvm-test-suite/MultiSource/Applications/ALAC/encode/main.cpp:int32_t main (int32_t argc, char * argv)
N.B. The use of int32_t is fine in the rest of the file (stdint.h is available).

Does anyone know what the problem is, and what is the correct solution?

Thank you

Robert

Hi,

I'm trying to get the 'test-suite' running using clang as a cross compiler
for XCore.

However I have hit the following problem:

    clang++ -c
llvm-test-suite/MultiSource/Applications/ALAC/decode/main.cpp --target=xcore
    llvm-test-suite/MultiSource/Applications/ALAC/decode/main.cpp:72:1:
error: 'main' must return 'int'
    int32_t main (int32_t argc, char * argv)
    ^
    llvm-test-suite/MultiSource/Applications/ALAC/decode/main.cpp:72:9:
error: first parameter of 'main' (argument count) must be of type 'int'
    int32_t main (int32_t argc, char * argv)
            ^
    2 errors generated.

However, running without the " --target=xcore" and all is fine.

The simple solution for me is to change 'int32_t' to 'int' in the two
problematic files' main functions viz:
    llvm-test-suite/MultiSource/Applications/ALAC/decode/main.cpp:int32_t
main (int32_t argc, char * argv)
    llvm-test-suite/MultiSource/Applications/ALAC/encode/main.cpp:int32_t
main (int32_t argc, char * argv)
N.B. The use of int32_t is fine in the rest of the file (stdint.h is
available).

Does anyone know what the problem is, and what is the correct solution?

The problem is that 'main' is required to take a parameter of type 'int'
and return a value of type 'int', and 'int32_t' is not necessarily 'int'.
The correct solution is to fix the code to use the right types, as you
suggested.

The problem is that ‘main’ is required to take a parameter of type ‘int’ and return a value of type ‘int’, and ‘int32_t’ is not necessarily ‘int’.
The correct solution is to fix the code to use the right types, as you suggested.

Thanks Richard.
This then leads to the question why the code builds without an error if the “–target” is not specified (not checked permutations).
By the way ‘int32_t’ is ‘int’ in this situation.
It would be nice if there was consistency…

Robert

Hi Richard,
My mistake, checked the wrong library!
newlib uses “typedef signed long int32_t;”
Thus the error is correct.
Robert