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 support@ccsinfo.com

[Explained] Prototype mismatching function - no warning?

 
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: 537
Location: Des Moines, Iowa, USA

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

[Explained] Prototype mismatching function - no warning?
PostPosted: Thu Jan 30, 2020 9:27 am     Reply with quote

Is there a way to enable a warning when something like this happens?

header file:
Code:
void foo(); // no return value


source file:
Code:
int16 foo() // returns an in16
{
   return 42;
}


A coworker had a mismatch in his code like this, and was getting a "Contact CCS" error and it wouldn't build. I tried to recreate that on my system, and don't get that error, but also don't get a warning.

When I use GCC, I crank up all the warnings. I'm not sure how to do that (if even possible) inside the CCS IDE.
_________________
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 ?


Last edited by allenhuffman on Thu Jan 30, 2020 9:35 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Thu Jan 30, 2020 9:32 am     Reply with quote

That won't give an error, unless the code tries to use the foo
function before it's declaration. It'll treat the prototype as being for
a different overloaded version of the function.
allenhuffman



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

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

PostPosted: Thu Jan 30, 2020 9:33 am     Reply with quote

Ah, a difference because of the C++ stuff that has moved into C. That makes sense.

Is there any way to turn on "prototypes required" in this compiler?
_________________
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 ?
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