Code: Select all
main.c:50: warning: return type of ‘main’ is not ‘int’
main.c: In function ‘main’:
main.c:63: warning: pointer targets in passing argument 1 of ‘puts’ differ in signedness
Code: Select all
main.c:50: warning: return type of ‘main’ is not ‘int’
main.c: In function ‘main’:
main.c:63: warning: pointer targets in passing argument 1 of ‘puts’ differ in signedness
Code: Select all
blocks.. :roll:
They mean that Bran hasn't been adhering to the C standard (at least, not the one you're trying to use to compile it). You're probably compiling it as C99, whereas it is written in C89 or older.nightfire8199 wrote:I have followed Bran's Tutorial on osdever.net to the dot on the i's (figuratively). but when it comes time to compile, gcc (in Linux) has some UBER-problem with everything I do. the main compile error output (for main.c only) is that main() is not an int or something to that regard. and that puts is not correct. Below is the actual output:
I'm not sure at all what this means, but I can tell that it isn't going to spit out a main.o, Help?Code: Select all
main.c:50: warning: return type of ‘main’ is not ‘int’ main.c: In function ‘main’: main.c:63: warning: pointer targets in passing argument 1 of ‘puts’ differ in signedness
Code: Select all
void main()
Code: Select all
main()
Code: Select all
int main()
If you are not sure what that means, and also if you think it prevents creating a main.o, you do not have the required knowledge to make an OS. Really.nightfire8199 wrote:I'm not sure at all what this means, but I can tell that it isn't going to spit out a main.o, Help?
Candy wrote:They mean that Bran hasn't been adhering to the C standard (at least, not the one you're trying to use to compile it). You're probably compiling it as C99, whereas it is written in C89 or older.nightfire8199 wrote:I have followed Bran's Tutorial on osdever.net to the dot on the i's (figuratively). but when it comes time to compile, gcc (in Linux) has some UBER-problem with everything I do. the main compile error output (for main.c only) is that main() is not an int or something to that regard. and that puts is not correct. Below is the actual output:
I'm not sure at all what this means, but I can tell that it isn't going to spit out a main.o, Help?Code: Select all
main.c:50: warning: return type of ‘main’ is not ‘int’ main.c: In function ‘main’: main.c:63: warning: pointer targets in passing argument 1 of ‘puts’ differ in signedness
The first means that you haveorCode: Select all
void main()
but the standard requires you to sayCode: Select all
main()
because it will always have an integer return value.Code: Select all
int main()
The second means that you pass a parameter to puts that isn't of the right type, where the old compiler didn't complain (most likely since you could call undeclared functions). New compilers do complain because it's just plain wrong.
No it doesn't. main() is no different to any other function. It is usually the first C/C++ function called in your code, but you can easily edit your assembly stub to change that.Craze Frog wrote:main() has a special meaning in C. Just rename your function k_main() or something and the warning will go away.
Not correct. In implementation main() is no different however it is defined to have a certain form by both the POSIX and C99 standards. Same with printf.MessiahAndrw wrote:No it doesn't. main() is no different to any other function. It is usually the first C/C++ function called in your code, but you can easily edit your assembly stub to change that.Craze Frog wrote:main() has a special meaning in C. Just rename your function k_main() or something and the warning will go away.
No, main has a special meaning. It means, "this is where I want the program execution to start". Just read the C99 standard, section 5.1.2.2.1. The same standard also prohibits any function named main to have any other return type than int. Which is the reason for the warning in GCC.MessiahAndrw wrote:No it doesn't. main() is no different to any other function. It is usually the first C/C++ function called in your code, but you can easily edit your assembly stub to change that.Craze Frog wrote:main() has a special meaning in C. Just rename your function k_main() or something and the warning will go away.
Source code:In implementation main() is no different...
Code: Select all
int crudebox() {
__asm__("#CODE START 2");
__asm__("#CODE END 2");
return 0;
}
int main() {
__asm__("#CODE START");
__asm__("#CODE END");
return 0;
}
Code: Select all
...
_crudebox:
pushl %ebp
movl %esp, %ebp
/APP
#CODE START 2
#CODE END 2
/NO_APP
popl %ebp
xorl %eax, %eax
ret
...
_main:
pushl %ebp
movl $16, %eax
movl %esp, %ebp
subl $8, %esp
andl $-16, %esp
call __alloca
call ___main
/APP
#CODE START
#CODE END
/NO_APP
leave
xorl %eax, %eax
ret
Aww man I just wanted to correct Crazy Frog on something to make him feel dumb after he posted this (and after reading that, click the link to his blog in his profile for more Linux and C bashing).JamesM wrote:Not correct. In implementation main() is no different however it is defined to have a certain form by both the POSIX and C99 standards. Same with printf.MessiahAndrw wrote:No it doesn't. main() is no different to any other function. It is usually the first C/C++ function called in your code, but you can easily edit your assembly stub to change that.Craze Frog wrote:main() has a special meaning in C. Just rename your function k_main() or something and the warning will go away.
Won't cause an error but will cause warnings.