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

Warnings during compile

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



Joined: 23 Dec 2022
Posts: 2

View user's profile Send private message

Warnings during compile
PostPosted: Fri Dec 23, 2022 8:19 am     Reply with quote

Hi,
I have a trial version of the latest compiler. But when I compile a program that was written (compiled and worked fine) with an old CCS compiler. The trial version throws up the following warning :

Warning - Interrupts disabled during call to prevent re-entrancy: (@PRINTF_LD_19200_31766_31767)

Is there a way to stop the interrupts being disabled automatically? I suspect that it is this that's causing the problems I'm experiencing.

Many thanks,
Les
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Fri Dec 23, 2022 8:28 am     Reply with quote

The warning is telling you that you have a function which is being called both inside and outside of an interrupt service routine. The compiler is telling you that when it encounters printf outside of an ISR, it's automatically wrapping it in a disable_interrupts(GLOBAL) ... enable_interrupts(GLOBAL) pair. If the compiler did not do this, then your program is sure to fail in practice. You can:

a) Refactor your code to remove the printf inside of an ISR. It's really bad practice to do anything slow inside of an ISR, particularly a print to some external stream of whatever sort. Or,
b) Take the lazy way out and wrap the printf you have outside of an interrupt inside your own function, my_printf(). This will cause the compiler to create a 2nd instance of the function and that will make the warning go away.

Finally, just because you didn't see this issue with an older version of the compiler doesn't mean it wasn't there. It just, for whatever reason, wasn't telling you about it.
Les



Joined: 23 Dec 2022
Posts: 2

View user's profile Send private message

PostPosted: Mon Dec 26, 2022 2:36 pm     Reply with quote

Thanks for the info.
The program was written using a CCS 2007 compiler, and built to work without conflicts. But the way in which it was done wasn't very elegant.
From your comments I've rewritten sections of the code. It now compiles without errors, works fine, and I feel more confident in it's operation.
Many thanks - sometimes a simple explanation goes a long way. :-)
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Tue Dec 27, 2022 7:19 am     Reply with quote

The older compilers still did this, but did not give you a warning.
They have to, because if not, it results in the code having to be re-entrant
(calling inside itself), and the PIC because it lacks a variable stack cannot
do this.
The warning was added to tell you that this was happening, so you could
potentially redesign the code to avoid it (it in many cases will be better
if you can avoid this).
The old compiler was doing this 'silently', the newer compilers tell you.

2007, would be a very early compiler. Late V3 possibly.
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