Open micro222 opened 10 years ago
What compiler are you using @micro222 ? I used gcc on Linux and everything compiled fine except for "atoi", which didn't come with gcc by default as it's not standard ANSI C. I replaced it with the better snprintf anyhow.
I can look at the warnings but it would help to know: 1) What compiler do you use now? 2) What compiler do you hope to use for your target platform? 3) What is the target platform? Raspberry Pi? Arduino? Do we know?
Ideally, it would be neat if we discover that we can use C99. I wouldn't be surprised if many embedded devices would have a C99 compiler for it, if not most.
1) It's listed in CodeBlocks as GNU GCC 2) GCC 3) I'm leaning towards anything that runs GNU/Linux. I just bought a Pi so it should run on that I imagine.
I read that C99 isn't fully implemented in Linux or Microsoft. What are the advantages to us?
Good point about C99, but all the features that I expect we would use are implemented in both by most major compilers now, AFAIK. I'm talking about things like being able to declare a variable somewhere other than at the beginning of a function (like inside a "for" statement), 1-liner comments with //, not having to typedef structs. Essentially, I'm talking about convenience here, so it's not a priority. There are other new important additions to C99, but they are less relevant to our project, I think. Also, using it is just a matter of flipping a switch (adding a flag to the compiler or checking a box in CodeBlocks). I think C99 is the current gold standard, whereas C11 might not have such widespread adoption yet. So I suggest switching over, although it is just a suggestion, especially since my knowledge of the landscape of C compilers for embedded hardware platforms is minimal. However, if we use the Pi then we'll have all C99 and C11 extensions guaranteed.
warning: assignment makes integer from pointer without a cast [enabled by default]| warning: format '%s' expects argument of type 'char ', but argument 3 has type 'int' [-Wformat]| warning: passing argument 1 of 'strcmp' makes pointer from integer without a cast [enabled by default]| note: expected 'const char ' but argument is of type 'char'| warning: passing argument 1 of 'sprintf' from incompatible pointer type [enabled by default]| note: expected 'char ' but argument is of type 'char *'| warning: "EOF" redefined [enabled by default]| warning: unknown conversion type character 't' in format [-Wformat]| warning: comparison between pointer and integer [enabled by default]| warning: control reaches end of non-void function [-Wreturn-type]| warning: array subscript is above array bounds [-Warray-bounds]|