atul
Tester

Reged: Jun 22 2008
Posts: 5
|
|
Macro string size can not be more than 31 characters.
I had two macros in my code
#define DEFAULT_CONTINOUS_MEMORY_HEADER_SECT 1 #define DEFAULT_CONTINOUS_MEMORY_HEADER_PAGE 4
when I compile code with Hitech it gives me Warning (111) of redefinition, while same macros works good with SDCC compiler.
Any Idea??
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3401
Loc: Boulder, Colorado U.S.A.
|
|
Quote:
Any Idea??
Check the "-N" C51 driver option described in the manual.
|
atul
Tester

Reged: Jun 22 2008
Posts: 5
|
|
OK, -N option works OK , but default 31 is too low size,
One more problem now, I want to increment value of content pointed by a pointer but that does not work the way Kernighan & Rictchie describes e.g. Code:
++*ptr; // Unable to evaluate expression in HiTech, works fine in SDCC
++(*ptr); // Unable to evaluate expression in HiTech, works fine in SDCC
(*prt)++; // Unable to evaluate expression in HiTech, works fine in SDCC
*ptr += 1; // Unable to evaluate expression in HiTech *ptr + 1; // Compiles OK in Hitech and SDCC but not sure about the result
Any idea what is the correct way to increment content pointed by a pointer compatible across compilers. 
- Atul
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3401
Loc: Boulder, Colorado U.S.A.
|
|
Quote:
Any idea what is the correct way to increment content pointed by a pointer compatible across compilers.
Code:
unsigned char c;
void main(void) { unsigned char *p = &c;
++*p;
for (;;); }
Compiles OK here, but my beta has expired, so no OCG in case that makes a difference.
|
clyde
HI-TECH team member
   
Reged: Oct 16 2003
Posts: 633
|
|
1) The reason the default identifier size is set at 31 is because this is the minimum required by the ANSI standard for external identifiers. A program that requires more significant characters than this cannot be a conforming ANSI C program, since there may be conforming compilers that will not compile that program.
This policy is fairly long-standing - it may be time to review it. There are probably few compilers now in common use that don't allow more than 31 characters.
2) It's impossible to tell from your post what might be the problem with the pointer arithmetic. Could you please post an example with enough detail to reproduce the problem, and also say what the actual error message is ("unable to evaluate" is not a message the compiler produces, AFAIK)
Regards, Clyde
|
clyde
HI-TECH team member
   
Reged: Oct 16 2003
Posts: 633
|
|
Dan, the beta serial number has been extended to the end of July. Just reactivate.
Clyde
|
atul
Tester

Reged: Jun 22 2008
Posts: 5
|
|
I am using c8051f411 MCU having 0x7FF XRAM. When I compiled my code with Hi-Tech compiler, it fails saying could not allocate 0x792 bytes in 'bss' segment which is XDATA.
Find the assembly file generated out of compilation for reference.
Please help why I am getting this error.
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3401
Loc: Boulder, Colorado U.S.A.
|
|
Thanks. I should have been paying closer attention.
|
clyde
HI-TECH team member
   
Reged: Oct 16 2003
Posts: 633
|
|
The current beta doesn't allocate the first 100h bytes of XDATA. This has been changed since. We expect to post a new beta version this week with this and numerous other improvements.
Clyde
|
atul
Tester

Reged: Jun 22 2008
Posts: 5
|
|
Quote:
2) It's impossible to tell from your post what might be the problem with the pointer arithmetic. Could you please post an example with enough detail to reproduce the problem, and also say what the actual error message is ("unable to evaluate" is not a message the compiler produces, AFAIK)
Regards, Clyde
Here is exact Error Message that comes during Linking
C51.exe --chip=c8051f411 --Output=eomf51 main.p1 powerup.obj uart.p1 ADC.p1 RTC.p1 Timer.p1 Util.p1 blackBox.p1 spi.p1 HI-TECH C 51-Pro Pro beta build 2241 V9.70 Copyright (C) 1984-2008 HI-TECH SOFTWARE Serial number: HC51P-117069242 this licence will expire on Wed, 30 Jul 2008 Totalrefs = 1996 spi.c: 177: (712) can't generate code for this expression (908) exit status = 1
and part of the code where it points as line no 177 is as:
Code:
for(g_bySPIIndex = 0; g_bySPIIndex < 128; g_bySPIIndex++) { // Send Data through SPI for up to a Page g_wSPIIndex = g_pwSPIDataBuffer[*g_pwSPIReadPointer];// Fetch a WORD from Buffer
SPI0DAT = (BYTE)(g_wSPIIndex&0xFF); // LSB while (SPIF == 0) ; // Wait till byte transmitted SPIF = 0; // Clear Interrupt Flag
SPI0DAT = (BYTE)((g_wSPIIndex>>8)&0xFF); // MSB while (SPIF == 0) ; // Wait till byte transmitted SPIF = 0; // Clear Interrupt Flag ++*g_pwSPIReadPointer; // Linker Error in this line //(*g_pwSPIReadPointer) + 1; // Work OK if(*g_pwSPIReadPointer >= g_wSPIReadMaxLimit) { // Reverse Buffer Traversal, when it reached to Max *g_pwSPIReadPointer = 0; } }
Pointer type is initialized as Code:
WORD *g_pwSPIReadPointer; // Pointer to content for Data buffer Read Pointer
and the same is made as extern also like Code:
extern WORD *g_pwSPIReadPointer; // Pointer to content for Data buffer Read Pointer
Best Regards Atul
|