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

Phantom Function calls
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 01, 2019 3:59 pm     Reply with quote

If you use quotes like below, the compiler will try to get the file
from your project files folder:
Code:
#include "string.h"


If you use angle brackets like below, it will get string.h from
the CCS drivers folder (the 5.078 version).
Code:
#include <string.h>

So use angle brackets.
Gabriel



Joined: 03 Aug 2009
Posts: 1077
Location: Panama

View user's profile Send private message

PostPosted: Mon Apr 01, 2019 8:13 pm     Reply with quote

Did that... still loaded from 5.013
_________________
CCS PCM 5.078 & CCS PCH 5.093
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 01, 2019 9:11 pm     Reply with quote

Another way is use quotes, and specify the full complete path to the
desired file.
Gabriel



Joined: 03 Aug 2009
Posts: 1077
Location: Panama

View user's profile Send private message

PostPosted: Tue Apr 02, 2019 11:53 am     Reply with quote

I still can get this code to compile due to the missing #endif - Which im not missing.

what could cause this error or how can i track it down.

I've started injecting random errors around the code to see where the compiler fails first due to my induced code error over the missing endif... but the results are ambiguous... I get errors in functions that have not changed in years, and even after an inspection i cant seem to find any thing wrong.

This has got me thinking the error might be in one of the standard library files but that isnt likely.

I did find a case mismatch on an #ifdef ending in a #ENDIF but that didnt solve anything on String.h
_________________
CCS PCM 5.078 & CCS PCH 5.093
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 02, 2019 12:04 pm     Reply with quote

Can you post a list of all the CCS provided source files (.c, .h)
that you are #including in your program ?

String.h ends like this:
Code:

/************************************************************/


#endif

Is it possible that you edited the file and assumed that the asterisk line
was the end, and you chopped off the #endif ?
Gabriel



Joined: 03 Aug 2009
Posts: 1077
Location: Panama

View user's profile Send private message

PostPosted: Tue Apr 02, 2019 12:18 pm     Reply with quote

Only these 2:

#include "C:\Program Files (x86)\PICC - 5.078\Drivers\string.h"
#include "C:\Program Files (x86)\PICC - 5.078\Drivers\stdlib.h"

Quote:
/************************************************************/


#endif


This is the end of the file as you described. i have not touched these files in any way EXCEPT changing 1 #ENDIF to #endif thinking it could be case mismatch... that had no effect like i mentioned earlier.

Most of the code im using its at least 2 or 3 years old... the code compiles fine in 5.013. i seriously doubt there is an #endif missing as i dont use them that frequently. i think something else is triggering this error.
_________________
CCS PCM 5.078 & CCS PCH 5.093
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 02, 2019 12:33 pm     Reply with quote

I can offer to look at it. You could zip up the project folder, post it to
Google Drive or something, with a password. Then give me the link
and the password in a PM. But, this may not be possible due to
an NDE from the customer.

So maybe I could list what I would do to find the problem. I will have
to think about what I would do.
Gabriel



Joined: 03 Aug 2009
Posts: 1077
Location: Panama

View user's profile Send private message

PostPosted: Tue Apr 02, 2019 12:49 pm     Reply with quote

yeah... I cant disclose the code.
Well ill try to fix the phantom calls using 5.013 by moving code around, smaller functions and the likes... see if that solves the issue in 5.078.

I think this is the same problem, just a different response in each compiler.
_________________
CCS PCM 5.078 & CCS PCH 5.093
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 02, 2019 1:22 pm     Reply with quote

Here is what I would do:

1. Zip up the project directory to preserve it. I want to be able
to freely "mess up" the source files without having to worry about
putting them back together later. The zip file will do that.

2. Put a text statement at the start of every source file, using a
pre-processor statement, to state the name of the file.
Then compile, and look in the Build output window. Confirm that
all files are listed there. This is done to check if some obscure old
file in a different folder is being accidently included and messing you
up. This old file might have a dangling #if statement in it.

3. Start commenting out driver files, one by one. Say you have ds1307.c
in your program. Comment out the #include line for it. Also comment
out any lines in your main or other source files that call its functions.
You may find the culprit by this method. Or all that's left may be
your main C source file. Also comment out .h files such as string.h
and comment out the lines in main.c that call those functions. Really
get in there and cut.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 03, 2019 12:54 am     Reply with quote

With some help from CCS support, I was able to duplicate this error:
Quote:

>>> Warning 236 "C:\Program Files (x86)\PICC - PCH - 5.013
\drivers\string.h" Line 54(9,16): Defined identifier matches a variable ID

Here is a test program that generates the error:
Code:
#include <18F87J50.h>
#fuses NOWDT
#use delay(crystal=20M)

int8 strcopy;

#include <string.h>

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

while(TRUE);
}

The error occurs because CCS has this line in string.h:
Quote:
#define strcopy strcpy

Somewhere in your source files, you have declared 'strcopy' as a variable.

Do a text search for strcopy in all your source files. If you find
a line where it's declared as a variable, change the name to something
unique. MPLAB has a "Find in Files" feature in the Edit menu to do this search.

--------------
It could be that one of these warnings is somehow implicated in the
#endif problem. So fix all these too:
Quote:
>>> Warning 230 Line 660(1,1): String truncated

This warning is caused by declaring an array that is too small to hold
the string. Example:
Code:
int8 msg[6]={"Hello World"};


Quote:
>>> Warning 203 Line 74(1,1): Condition always TRUE

This warning is usually caused by using while(1) instead of while(TRUE).
It could also be caused by an expression in an if() statement or a for()
loop that evaluates to always be TRUE.
Ttelmah



Joined: 11 Mar 2010
Posts: 20057

View user's profile Send private message

PostPosted: Wed Apr 03, 2019 3:08 am     Reply with quote

Can I make a suggestion.

I've had issues like this in the past, and simple text searches are the place
to start.

So, if you have the IDE, select 'find in files'. Then 'files in project', then
type #IF, and do a search. Then go to the results screen, and select
everything. Copy. Paste this into an empty text document.
Then repeat this, searching for #ENDIF. Paste the results of this into a
second text document.
Now look at these side by side.
How many lines do they both have?.
There may well be differences (for instance, the USB drivers have a few
places with #IF statements 'remmed' out), so you will find lines with
//#IF. These obviously don't have matching #ENDIF's. However if you
look at how many lines are in each file with matching 'file location'
entries, it gives you a very strong place to start looking. For instance
doing this on a small project here, I have ten lines in the #IF file
for a particular #include, and a matching ten lines in the #ENDIF
file. This allows you to reduce the number of places that need to
be actually inspected..... You can concentrate your search on the files
where there is an imbalance. Smile
Gabriel



Joined: 03 Aug 2009
Posts: 1077
Location: Panama

View user's profile Send private message

PostPosted: Thu Apr 04, 2019 11:08 am     Reply with quote

So, After extensive code commenting and going through what felt like thousands of un-comment/compile cycles the error is triggered by this:

Code:
#ifndef CLOUD_WIFI
   void UTF8_ENCODE(char symbol)
   {
      char Temp_string[]="x";
      Temp_string[0]=symbol;
      switch(symbol)
      {
         case '{':
         {
            strcat(Post_Buffer,"%7B");
            break;
         }
         case '}':
         {
            strcat(Post_Buffer,"%7D");
            break;
         }
         case '"':
         {
            strcat(Post_Buffer,"%22");
            break;
         }
         case ''':
         {
            strcat(Post_Buffer,"%27");
            break;
         }
         case ':':
         {
            strcat(Post_Buffer,"%3A");
            break;
         }
         case ',':
         {
            strcat(Post_Buffer,"%2C");
            break;
         }
         case '[':
         {
            strcat(Post_Buffer,"%5b");
            break;
         }
         case ']':
         {
            strcat(Post_Buffer,"%5d");
            break;
         }
         default:
         {
            strcat(Post_Buffer,Temp_string);
            break;
         }
      }
   }
   
   void CLEAR_POST()
   {
      memset(Post_Buffer,NULL,POST_BUFFER_SIZE);      // Set all elements to NULL
      Post_Buffer_Index=0;                     // Reset index
   }
#endif



These functions are declared on the driver file as follows:
Code:
// Functions enabled if only using GPRS
   #ifndef CLOUD_WIFI
      #define UPLOAD 1
      #define DOWNLOAD 0
      #define POST_BUFFER_SIZE 400      //GPRS/WIFI - For all internet Connections
      char Post_Buffer[POST_BUFFER_SIZE];   //GPRS/WIFI - For all internet Connections   
      int16 Post_Buffer_Index=0;

      void UTF8_ENCODE(char);
      void CLEAR_POST();   
   #endif



The declaration does not cause the error, only the definition of the functions.
which are clearly NOT missing an #endif.


These 2 functions are part of my Wifi Driver, but in some cases when my device/application only has a GPRS connection, the GPRS driver checks to see if "CLOUD_WIFI" is defined and if not, it declares and defines the functions because they will be needed for GPRS.

maybe your eyes will see something im not seeing that may cause the #endif error, which somehow is not caused by a missing #endif.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Gabriel



Joined: 03 Aug 2009
Posts: 1077
Location: Panama

View user's profile Send private message

PostPosted: Thu Apr 04, 2019 12:07 pm     Reply with quote

Related to previous responses:

Quote:
>>> Warning 230 Line 660(1,1): String truncated

This is caused by me purposely inserting a "\0" shorten a string.

Code:
Balance[(strlen(Balance))-1]="\0";   //There is an extra "." on the string we need to remove.


Quote:
Do a text search for strcopy in all your source files. If you find
a line where it's declared as a variable, change the name to something
unique. MPLAB has a "Find in Files" feature in the Edit menu to do this search.


I did the search - No matches...

I have 2 while(1) which i've changed to TRUE - I didnt know it made a diference
_________________
CCS PCM 5.078 & CCS PCH 5.093
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 04, 2019 12:37 pm     Reply with quote

I made a little test program, but unfortunately I don't get any errors when
compiled with vs. 5.078.
Quote:
Compiling C:\Program Files\PICC\Projects\PCH_Test\PCH_Test on 04-Apr-19 at 11:33
Memory usage: ROM=0% RAM=11% - 12%
0 Errors, 0 Warnings.
Build Successful.
Loaded C:\Program Files\PICC\Projects\PCH_Test\PCH_Test.cof.
BUILD SUCCEEDED: Thu Apr 04 11:33:30 2019

Test program:
Code:
#include <18F87J50.h>
#device PASS_STRINGS=IN_RAM
#fuses NOWDT
#use delay(crystal=20M)
#use rs232(baud=9600, UART1, ERRORS)

#include <string.h>

// Functions enabled if only using GPRS
   #ifndef CLOUD_WIFI
      #define UPLOAD 1
      #define DOWNLOAD 0
      #define POST_BUFFER_SIZE 400      //GPRS/WIFI - For all internet Connections
      char Post_Buffer[POST_BUFFER_SIZE];   //GPRS/WIFI - For all internet Connections   
      int16 Post_Buffer_Index=0;

      void UTF8_ENCODE(char);
      void CLEAR_POST();   
   #endif



#ifndef CLOUD_WIFI
   void UTF8_ENCODE(char symbol)
   {
      char Temp_string[]="x";
      Temp_string[0]=symbol;
      switch(symbol)
      {
         case '{':
         {
            strcat(Post_Buffer,"%7B");
            break;
         }
         case '}':
         {
            strcat(Post_Buffer,"%7D");
            break;
         }
         case '"':
         {
            strcat(Post_Buffer,"%22");
            break;
         }
         case ''':
         {
            strcat(Post_Buffer,"%27");
            break;
         }
         case ':':
         {
            strcat(Post_Buffer,"%3A");
            break;
         }
         case ',':
         {
            strcat(Post_Buffer,"%2C");
            break;
         }
         case '[':
         {
            strcat(Post_Buffer,"%5b");
            break;
         }
         case ']':
         {
            strcat(Post_Buffer,"%5d");
            break;
         }
         default:
         {
            strcat(Post_Buffer,Temp_string);
            break;
         }
      }
   }
   
   void CLEAR_POST()
   {
      memset(Post_Buffer,NULL,POST_BUFFER_SIZE);      // Set all elements to NULL
      Post_Buffer_Index=0;                     // Reset index
   }
#endif

//==========================
void main()
{
char temp;

temp = '{';

UTF8_ENCODE(temp);
CLEAR_POST();


while(TRUE);
}   
Gabriel



Joined: 03 Aug 2009
Posts: 1077
Location: Panama

View user's profile Send private message

PostPosted: Thu Apr 04, 2019 12:45 pm     Reply with quote

As suggested by Ttelmah, did the #if/#endif Search - 31 matches for each. all corresponding to the right files and locations.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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