|
|
View previous topic :: View next topic |
Author |
Message |
allenhuffman
Joined: 17 Jun 2019 Posts: 552 Location: Des Moines, Iowa, USA
|
CCS option to require prototypes? |
Posted: Wed Feb 05, 2020 2:51 pm |
|
|
Is there a CCS option to require prototypes? From another topic, someone said if there wasn't a match, it would look for an overload (no prototype, so I guess that would be int/int like normal C?).
A test function that wants a structure will silently allow pretty much anything but floats and string constants without warnings. GCC has flags to prevent that.
Code: |
// These are allowed:
TestStruct temp;
Test(temp);
Test(12);
Test('a');
char *string = "Hello world!";
Test(string);
// These won't work:
/*
Test();
float f = 3.14;
Test(f);
double d = 3.14;
Test(d);
*/
|
Just curious if there's the opposite of #ignore_warnings or something that cranks them up. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Thu Feb 06, 2020 4:50 am |
|
|
It is never required in C to have prototypes.
It is required to have a function declaration 'in scope' before a function
is used. Though even this some compilers don't enforce.
<https://stackoverflow.com/questions/2575153/must-declare-function-prototype-in-c>
In particular look at the first answer, and then the first comment to this. |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 552 Location: Des Moines, Iowa, USA
|
|
Posted: Thu Feb 06, 2020 8:38 am |
|
|
Thank you, though I am not asking if the C standard requires prototypes I am asking for an option to do this in the CCS compiler, like other compilers have. You can enable all kinds of strictness in many tool suites to catch things that would otherwise pass by as "legal" (but wrong) code.
Let me add some GCC / GNU-C keywords for future searchers:
Eventually we need to get a LINT working, though some tests I did were problematic because of all the #use / #fuses and other extensions. Gotta spend some time finding one that can be customized to ignore non-C things in a C file. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Thu Feb 06, 2020 12:44 pm |
|
|
If you want to ask for a feature, then ask CCS.
Understand this forum is for user questions, not feature requests. |
|
|
allenhuffman
Joined: 17 Jun 2019 Posts: 552 Location: Des Moines, Iowa, USA
|
|
Posted: Thu Feb 06, 2020 12:47 pm |
|
|
Ttelmah wrote: | If you want to ask for a feature, then ask CCS.
Understand this forum is for user questions, not feature requests. |
I take it the answer is "you can ignore, but you can't enable" so, no, it has no way to do this. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Feb 07, 2020 3:30 am |
|
|
'Requiring' prototypes, was never a feature of C.
C++ has this.
However some C compilers introduced a similar capability.
If you want such an ability, you need to talk to CCS, and ask them if they
would consider introducing such an ability. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|