![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Im trying to make a member of this struct reference another instance of the same struct. Code: typedef struct MenuItem
{
//Pointer to the an array of menuitems that represents the next level of heirarchy.
MenuItem *nextLevel;
}MenuItem; Can this not be done in c? | |
| |
| | (permalink) |
| Would it be okay to do this instead, and then cast later? Code:
typedef struct MenuItem
{
//Pointer to the an array of menuitems that represents the next level of heirarchy.
void *nextLevel;
}MenuItem; | |
| |
| | (permalink) |
| Would it be, Code: typedef struct MenuItem
{
//Pointer to the an array of menuitems that represents the next level of heirarchy.
near rom * MenuItem;
}MenuItem; | |
| |
| | (permalink) |
| BTW, I added a message print routine to your code that uses a rom pointer. Code: void PutMessage(char rom*);
void PutMessageAt(unsigned char,unsigned char,char rom*);
void main(void){
InitLCD();
PutMessage((rom char*) "Hello World!");
PutMessageAt(3,2,(rom char*) "3 in on Line 2");
while(1);
}
//Write a string to the LCD
void PutMessage(char rom *Message){
while(*Message!=0)
WriteChar(*Message++);
}
//Set position and write string.
void PutMessageAt(unsigned char X,unsigned char Y,char rom *Message){
WriteCommand(0x80+(--Y<<6)+--X);
while(*Message!=0)
WriteChar(*Message++);
} | |
| |
| | (permalink) |
| Ok thanks mike. out of interest, which memory would my old code point to? Thanks. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| Pointers on the pic are confusing. The default is that pointers point to ram. I'm slowly getting comfortable with the types of pic pointers and have just realised that the cast on the function call is now not needed, this is from when I was trying everything to get it working. So, Code: PutMessage("Hello World!"); Mike. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| C18 compiler. Compiling custom libraries. | HerbertMunch | Micro Controllers | 5 | 30th December 2007 04:29 AM |
| Problem setting up timer Interrupt using C18 compiler | elec123 | Micro Controllers | 4 | 14th November 2007 11:59 AM |
| Regarding the CCS Compiler | 3v0 | Micro Controllers | 5 | 24th March 2007 10:22 PM |
| Help, CCS PIC-C Compiler... | Kenton | Micro Controllers | 17 | 3rd April 2006 12:48 AM |
| Atmel AVR free compiler and support free forum | mramos1 | Micro Controllers | 3 | 24th October 2005 09:00 AM |