CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

CCS option to require prototypes?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
allenhuffman



Joined: 17 Jun 2019
Posts: 552
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

CCS option to require prototypes?
PostPosted: Wed Feb 05, 2020 2:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 06, 2020 4:50 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Thu Feb 06, 2020 8:38 am     Reply with quote

Thank you, though I am not asking if the C standard requires prototypes Smile 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:

Code:
-Wall
-Wextra


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

View user's profile Send private message

PostPosted: Thu Feb 06, 2020 12:44 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Thu Feb 06, 2020 12:47 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Feb 07, 2020 3:30 am     Reply with quote

'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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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