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

#warning preprocessor

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



Joined: 24 Nov 2011
Posts: 2

View user's profile Send private message

#warning preprocessor
PostPosted: Thu Nov 24, 2011 9:29 pm     Reply with quote

Hi, Why do I get a 'Invalid pre-processor directive' message when I try to compile this?:
Code:

#define BOOT_COMPILE   // comment out for normal compile

#ifdef BOOT_COMPILE
   #warning  COMPILING AS BOOTLOADER
#else
   #include <bootloader.c>
#endif

The #warning text turns blue in MPLAB so I would have thought that means it is recognized? I've tried lots of combinations of case/quotes/brackets etc.

thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 24, 2011 10:08 pm     Reply with quote

Are you using the CCS compiler ? If I compile the test program shown
below with vs. 4.127, and I enable warnings in the MPLAB Project / Build
Options, I get this output. It's working:
Quote:

Executing: "C:\Program Files\PICC\Ccsc.exe" "PCH_Test.c" +FH +DF +LN -T -A +M -Z +Y=9 +EA
>>> Warning 224 "PCH_Test.c" Line 9(12,38): #warning COMPILING AS BOOTLOADER
>>> Warning 203 "PCH_Test.c" Line 20(1,1): Condition always TRUE

Memory usage: ROM=0% RAM=0% - 0%
0 Errors, 2 Warnings.
Loaded C:\Program Files\PICC\Projects\PCH_Test\PCH_Test.cof.
BUILD SUCCEEDED: Thu Nov 24 20:05:09 2011


If it doesn't work for you, then post your compiler version and post a
very short test program. ("short" means not much longer than the
following program).
Code:

#include <18F452.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#define BOOT_COMPILE   // comment out for normal compile

#ifdef BOOT_COMPILE
   #warning  COMPILING AS BOOTLOADER
#else
   #include <bootloader.c>
#endif

//====================================
void main()
{

     
while(1);
}
doctech



Joined: 24 Nov 2011
Posts: 2

View user's profile Send private message

PostPosted: Thu Nov 24, 2011 10:23 pm     Reply with quote

We use an older version 4.032. I tried a new project using the code you posted and I still get the compile error. I also tried loading an example project in the CCS IDE and it doesn't like #warning either.

Starting to sound like a compiler bug to me but I can't see it mentioned in the list of fixes. (maybe they don't go back that far).
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Fri Nov 25, 2011 2:53 am     Reply with quote

If you watched the forum at the time when you got that compiler, you would find it was really 'beta', with people telling you to use 3.249, rather than a V4 compiler. V4 only started to properly work around the late 4.06x version. Before this, very basic code might work, but probably in excess of 30% of things had problems....
I'm afraid 4.032, is likely to give you a lot more problems than this.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 25, 2011 3:10 pm     Reply with quote

CCS added support for #warning in compiler vs. 4.069. You have
vs. 4.032 so it doesn't support it.

You are probably using the current CCS manual, but it's for a much later
version. Your version (4.032) was released on about April 19, 2007.
Probably you should use the August 2007 manual. It's the last manual
that doesn't have #warning documented in it. The next earlier manual is
dated January 2007:
Quote:

C Compiler Reference Manual Version 4 August 2007

Here are two places you can still get the August 2007 manual. I found
these with Google:
http://www.bpcd.net/teacher/electrical/web/dspic/PCWReferenceManual.pdf
http://www.bairesrobotics.com.ar/data/ccs_picc_actualizado_2007.pdf
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