4 ms·
" it's valid for C code to define the main() function as something other than int." It's a bit more complicated than that. True, C defines two environments cal
by knz42 14y ago
" it's valid for C code to define the main() function as something other than int."
It's a bit more complicated than that. True, C defines two environments called "freestanding" (without OS) and "hosted" (with OS). As per the ISO specification (sect. 5.1.2.2.1 for both 9899:1999 and :2011), main() must return int for hosted implementations, whereas anything goes in freestanding.
Meanwhile, while it is true that most embedded systems are indeed "freestanding" as per the C standard, an increasing number is not. So one needs to be careful about these things.