Getting an "Type alt_up_character_lcd_dev could not be resolved" error

93 Views Asked by At

I've been working on try to display anything on the LCD screen using the Nios processor and the DE10-Lite board for weeks. I finally found a code that may help, but the I've been unable to shake off this error message, the code I found is

#include <string.h>
#include <system.h>
#include <altera_up_avalon_character_lcd.h>


int main(void)
{
 alt_up_character_lcd_dev * char_lcd_dev;

// open the Character LCD port
char_lcd_dev = alt_up_character_lcd_open_dev ("/dev/character_lcd_0");

if ( char_lcd_dev == NULL)
alt_printf ("Error: could not open character LCD device\n");
else
alt_printf ("Opened character LCD device\n");

/* Initialize the character display */
alt_up_character_lcd_init (char_lcd_dev);

/* Write "Welcome to" in the first row */
alt_up_character_lcd_string(char_lcd_dev, "Welcome to");

/* Write "the DE2 board" in the second row */
char second_row[] = "the DE10 Lite";
alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1);
alt_up_character_lcd_string(char_lcd_dev, second_row);
}

the error is on the second line after int main(void) writing alt_up_character_lcd_dev * char_lcd_dev;

I'm using a DE10-Lite board, the platform designer for the connections and a 16x2 LCD OSEPP screen.

How do I fix this error?

2

There are 2 best solutions below

0
Louis Go On BEST ANSWER

In the header, the typedef uses the same name (alt_up_character_lcd_dev) for both the struct tag and the typedef alias.

My assumption is that your compiler is confused by this. (but gcc doesn't have this issue)

To fix it,

struct alt_up_character_lcd_dev* char_lcd_dev;

might help.

0
Clifford On

It is not a compiler error; it is a message from your C language aware IDE or code editor (presumably Eclipse based?), and it is clearly confused (and wrong). You can ignore it and build regardless to see what the actual compiler makes of it. No doubt it will build just fine.

The problem is caused by the typedef of alt_up_character_lcd_dev in altera_up_avalon_character_lcd.h:

typedef struct alt_up_character_lcd_dev {
    /// @brief character mode device structure 
    /// @sa Developing Device Drivers for the HAL in Nios II Software Developer's Handbook
    alt_dev dev;
    /// @brief the base address of the device
    unsigned int base;
} alt_up_character_lcd_dev;

Note that both the the typedef alias and the struct tag are both alt_up_character_lcd_dev and your code editor is confused by that even though it is entirely valid. You can handle the "problem" in several ways, including:

  • Ignore it, it will compile anyway.
  • Remove the struct tag to make alt_up_character_lcd_dev and alias to an anonypous struct:
    typedef struct {
      ...
    } alt_up_character_lcd_dev;
    
  • Ignore the type-alias and specify the type struct alt_up_character_lcd_dev everywhere you use it - gets a bit "wordy".