• AVR Freaks

Hot!XC8 v2.05 C99 compiler error

Page: < 123 > Showing page 2 of 3
Author
mbrowning
USNA79
  • Total Posts : 1582
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/06 10:32:17 (permalink)
+1 (1)
Whether you are using floats in your code or not, you need to change the size of floats to 32bit in the project properties (XC8 Linker -> Memory model). Otherwise you will get that error.
 
This was pointed out by 1and0 in post #4
#21
jtemples
عُضْوٌ جَدِيد
  • Total Posts : 11519
  • Reward points : 0
  • Joined: 2004/02/13 12:31:19
  • Location: Southern California
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/06 10:45:01 (permalink)
+1 (1)
Why there is a 24-bit floating point types are not supported error?

 
Because you have 24-bit floating point enabled in your IDE project settings.
#22
1and0
Access is Denied
  • Total Posts : 10219
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/06 10:46:18 (permalink)
0
It'd be nice when selecting C99 standard would automatically update the sizes of float and double to 32 bits, when OK is clicked. ;)
 
post edited by 1and0 - 2019/09/06 10:48:23
#23
jtemples
عُضْوٌ جَدِيد
  • Total Posts : 11519
  • Reward points : 0
  • Joined: 2004/02/13 12:31:19
  • Location: Southern California
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/06 12:29:07 (permalink)
0
1and0
It'd be nice when selecting C99 standard would automatically update the sizes of float and double to 32 bits, when OK is clicked. ;)



Or just make it the default for both standards?
#24
mouchuanlin
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2019/01/23 12:41:10
  • Location: 0
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/06 13:48:23 (permalink)
0
There is no .map file until successfully compiled.
 
I created a new project and copy all of source files to the new project folder, now am able to compile. Although still don't have too much clue about the float 24 things.
 
I did see another issue of calling isdigit() function got warning - warning: (759) expression generates no code
 
}else if( isdigit(temp))
 
Any suggestions?
 
Thx
#25
jtemples
عُضْوٌ جَدِيد
  • Total Posts : 11519
  • Reward points : 0
  • Joined: 2004/02/13 12:31:19
  • Location: Southern California
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/06 14:07:07 (permalink)
+1 (1)
If I had to guess it's that the code you haven't shown is always true.
#26
mouchuanlin
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2019/01/23 12:41:10
  • Location: 0
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/06 15:30:01 (permalink)
0
It's not always true - see below. Thx
 
  do{
   temp = key[cnt++];
   if( temp=='#' )
   {
    if( cnt==0x04 || addr>30 )
     return('E');
    write_ee(0x00,0x7f,addr);
    return('K');
   }else if( isdigit(temp) )
   {
    temp &=0x0f;
    addr = addr*10U + temp;
   }else return('E');
  }while(cnt<0x06);


 
 
 
#27
mouchuanlin
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2019/01/23 12:41:10
  • Location: 0
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 09:07:55 (permalink)
0
 
I read this from PIC faq and use a temp variable to hold the value of isdigit(). Doesn't seems working.
 
I am wondering if this has anything to do with the macro define.
 
#ifndef __cplusplus
#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26)
#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)
 
https://microchipdeveloper.com/faq:48
What does an error like "Can’t generate code" mean?
The error means that the compiler tried but was unable to generate output for the indicated C source. It usually does not indicate that the C code is invalid, but review the code to be sure.
This error will most likely occur with complex expressions, particularly on devices with few working registers and simple architectures, e.g. baseline devices. Remember that C code that may not look complicated to you may be very difficult to implement in assembly code.
The solution is to try to simplify the expression, maybe using a temporary variable to hold an intermediate result. The compiler often has to resort to using compiler-defined temporary variables to hold intermediate results so this work around is often no less efficient that what would be otherwise possible.
#28
1and0
Access is Denied
  • Total Posts : 10219
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 09:32:35 (permalink)
0
mouchuanlin
I read this from PIC faq and use a temp variable to hold the value of isdigit(). Doesn't seems working.
 
I am wondering if this has anything to do with the macro define.
 
#ifndef __cplusplus
#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26)
#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)

The true value of these macros will never execute; hence no code is generated. That said, why are you using these macros?  Why not just #include <ctype.h> ?
 
 
#29
mbrowning
USNA79
  • Total Posts : 1582
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 09:40:04 (permalink)
0
Absolutely - The conditional operator condition is always false, so the first expression is never evaluated - thus no code. Seems an odd way to define a macro.
 
It is defined differently in C90 ctype.h
#30
mbrowning
USNA79
  • Total Posts : 1582
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 09:40:58 (permalink)
+1 (1)
1and0
Why not just #include <ctype.h> ?

These macros are in the C99 ctype.h
#31
1and0
Access is Denied
  • Total Posts : 10219
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 09:55:01 (permalink)
0
mbrowning
1and0
Why not just #include <ctype.h> ?

These macros are in the C99 ctype.h

Indeed. Surreal!
 
#32
jtemples
عُضْوٌ جَدِيد
  • Total Posts : 11519
  • Reward points : 0
  • Joined: 2004/02/13 12:31:19
  • Location: Southern California
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 10:29:48 (permalink)
0
I see different  macros on my system in .../v2.05/pic/include/c99/ctype.h
#33
mouchuanlin
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2019/01/23 12:41:10
  • Location: 0
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 12:21:32 (permalink)
0
This is the file from
C:\Program Files (x86)\Microchip\xc8\v2.05\pic\include\c99
#34
jtemples
عُضْوٌ جَدِيد
  • Total Posts : 11519
  • Reward points : 0
  • Joined: 2004/02/13 12:31:19
  • Location: Southern California
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 12:28:53 (permalink)
0
Never mind, I wasn't looking at what I thought I was looking at.
#35
mouchuanlin
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2019/01/23 12:41:10
  • Location: 0
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 12:53:21 (permalink)
-1 (1)
I don't really understand this macro in ctype.h  See below.
The only thing need to check is the value in between 0x30 and 0x39. Why make it so complicated?
 
#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)
#36
1and0
Access is Denied
  • Total Posts : 10219
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 12:57:29 (permalink)
0
mouchuanlin
I don't really understand this macro in ctype.h  See below.
The only thing need to check is the value in between 0x30 and 0x39. Why make it so complicated?
 
#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10)

It should be just
#define isdigit(a)  (((unsigned)(a)-'0') < 10)

#37
mouchuanlin
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2019/01/23 12:41:10
  • Location: 0
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 13:10:13 (permalink)
0
I just download 2.10, same function. I am wondering if there is any hot fix for this.
#38
jtemples
عُضْوٌ جَدِيد
  • Total Posts : 11519
  • Reward points : 0
  • Joined: 2004/02/13 12:31:19
  • Location: Southern California
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 13:50:42 (permalink)
0
Just put it in your code and don't include ctype.h.
 
#39
mouchuanlin
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2019/01/23 12:41:10
  • Location: 0
  • Status: offline
Re: XC8 v2.05 C99 compiler error 2019/09/09 13:53:31 (permalink)
0
That's what I did but in the long run, Microchip needs to fix this, right?
#40
Page: < 123 > Showing page 2 of 3
Jump to:
© 2020 APG vNext Commercial Version 4.5