It is currently 23 Apr 2018 16:33

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: 15 Apr 2018 19:10 
Offline

Joined: 24 Jun 2007 19:27
Posts: 982
Location: 01120 Dagneux France
Hello,

:x i am very disapointed with MikroC Pro ,
i loosed a couple of hours to discover a problem , due to the compiler ...

i used this function :

/*
void strConstRamCpy(unsigned char *dest, const code char *Source)
{
  while (*Source)  *(dest++) = *(Source++) ;
  *(dest)=0;
}
   


and get this message windows

Quote:
189 300 Syntax Error: ')' expected, but '"Mini_DDS_12F1840"' found Mini_DDS_12F1840_180415.c
192 402 ; expected, but '=' found Mini_DDS_12F1840_180415.c
192 371 Specifier needed Mini_DDS_12F1840_180415.c
192 396 Invalid declarator expected'(' or identifier Mini_DDS_12F1840_180415.c
193 371 Specifier needed Mini_DDS_12F1840_180415.c
193 396 Invalid declarator expected'(' or identifier Mini_DDS_12F1840_180415.c
196 393 '' Identifier redefined Mini_DDS_12F1840_180415.c
196 300 Syntax Error: '(' expected, but '{' found Mini_DDS_12F1840_180415.c
0 102 Finished (with errors): 15 avr. 2018, 18:07:38 Mini_DDS_12F1840.mcppi


an looked for an error inside my code .. without success
so i divided my code into many branch , to detect where the compile became wrong..
i discover problem was due to the above function ..

i just replaced the variable Source .. by source

void strConstRamCpy(unsigned char *dest, const code char *source)
 {
  while (*source) *(dest++) = *(source++) ;
  *dest = 0 ;    // terminateur
}

then i get a correct compiling

Quote:
0 1144 Used RAM (bytes): 168 (70%) Free RAM (bytes): 72 (30%) Used RAM (bytes): 168 (70%) Free RAM (bytes): 72 (30%)
0 1144 Used ROM (program words): 4058 (99%) Free ROM (program words): 38 (1%) Used ROM (program words): 4058 (99%) Free ROM (program words): 38 (1%)
0 125 Project Linked Successfully Mini_DDS_12F1840.mcppi
0 128 Linked in 47 ms
0 129 Project 'Mini_DDS_12F1840.mcppi' completed: 281 ms
0 103 Finished successfully: 15 avr. 2018, 19:43:42 Mini_DDS_12F1840.mcppi



my project

Attachment:
_Mini_DDS_12F1840.zip [126.35 KiB]
Downloaded 8 times


Why ?
is Source a reserved WORD ?

i allready get same kind of problem, in another application
because use of vraibale p
like this
char *p;
Compile error .. line error everywhere .. not on this problem!
at list..
i changed by
char *p1;
Compile OK


Where is the complete list a reserved word (variable name) used by the compiler ?


Top
 Profile  
 
PostPosted: 16 Apr 2018 07:36 
Offline

Joined: 04 Oct 2010 07:16
Posts: 27
Location: Austria
You already have an define in your code:

#define Source "Mini_DDS_12F1840"

That's the mistake.

Peter


Top
 Profile  
 
PostPosted: 16 Apr 2018 09:30 
Offline

Joined: 24 Jun 2007 19:27
Posts: 982
Location: 01120 Dagneux France
hello,

PARBLEU, mais c'est bien sur !

Thank's for your help..

Normally, global variable are separate from local variable ..

if i add in my globale variable :
unsigned char *source;

and use
void strConstRamCpy(unsigned char *dest, const code char *source)
 {
  while (*source) *(dest++) = *(source++) ;
  *dest = 0 ;    // terminateur
}


i get NO errors in compile ..

does it means that #define = reserved name for only one variable into the program ?


Top
 Profile  
 
PostPosted: 16 Apr 2018 10:08 
Offline

Joined: 04 Oct 2010 07:16
Posts: 27
Location: Austria
#define works like find and replace, similar to a macro. This does not define a variable or constant.

Your *Source will change to *"Mini_DDS_12F1840".

I'm not quite sure, though.

Peter


Top
 Profile  
 
PostPosted: 16 Apr 2018 14:43 
Offline
mikroElektronika team
User avatar

Joined: 25 Jan 2008 09:56
Posts: 9700
Hi,

Yes PeDre, you are right about this, please find the explanation from the mikroC PRO for PIC Help file, section Macros :

Quote:
The #define directive defines a macro:
#define macro_identifier <token_sequence>
Each occurrence of macro_identifier in the source code following this control line will be replaced in the original position with the possibly empty token_sequence (there are some exceptions, which are discussed later). Such replacements are known as macro expansions.token_sequence is sometimes called the body of a macro. An empty token sequence results in the removal of each affected macro identifier from the source code.

Regards,
Filip.


Top
 Profile  
 
PostPosted: 16 Apr 2018 19:43 
Offline

Joined: 24 Jun 2007 19:27
Posts: 982
Location: 01120 Dagneux France
filip wrote:
Hi,


Quote:
The #define directive defines a macro:
#define macro_identifier <token_sequence>
Each occurrence of macro_identifier in the source code following this control line will be replaced in the original position with the possibly empty token_sequence (there are some exceptions, which are discussed later). Such replacements are known as macro expansions.token_sequence is sometimes called the body of a macro. An empty token sequence results in the removal of each affected macro identifier from the source code.

Regards,
Filip.


Ok, i learned one more think ..

but what about the use of variable p as pointer , like
char *p;
causing compile error
(not used in a #define , in my code .. or in other external #define ?)

is "p" a reserved word ?
or a #define
or a macro

nota: i allways use "case sensiitve checked"
to avoid more mistake between name variables.


Top
 Profile  
 
PostPosted: 16 Apr 2018 21:02 
Offline

Joined: 04 Oct 2010 07:16
Posts: 27
Location: Austria
I can't make the error, *p works for me.
Do you have a sample project?
The line number of the error message is sometimes wrong, a zero is missing at the end, e.g. 47 is then 470.

Peter


Top
 Profile  
 
PostPosted: 17 Apr 2018 20:13 
Offline

Joined: 24 Jun 2007 19:27
Posts: 982
Location: 01120 Dagneux France
hello,

example ...
if i add
char *p;

.. i get the error

error appears when "compiler case sensitive" is unchecked ..
it is why, now, i allways use Checked ..

Attachment:
Capture.JPG
Capture.JPG [ 130.46 KiB | Viewed 58 times ]


code :
Attachment:


Top
 Profile  
 
PostPosted: 18 Apr 2018 07:36 
Offline

Joined: 04 Oct 2010 07:16
Posts: 27
Location: Austria
I can reproduce the error. I always use the case sensitive option, so it worked before.

Peter


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


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 post attachments in this forum

Search for:
Jump to: