Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PC-Lint errors when using direct register addressing

I have an existing C-code (3rd party source, I can't change it) which will not be accepted by PC-Lint (Version 9.0). The code is running in an embedded environment, Green Hills Compiler is used.

Has anyone know-how on how to configure PC-Lint to accept the code definition? I have attached only the error message for the first member in the struct.

Here are the defines from header file:

typedef struct  
{  
    uint32_t PINSEL0;  // see ERROR message from PCLint, line 153 in LPC23.h  
    uint32_t PINSEL1;  
    uint32_t PINSEL2;  
} LPC_PINCON_TypeDef;


#define LPC_PINCON_BASE           (0xE002C000)
#define LPC_PINCON                ((LPC_PINCON_TypeDef *) LPC_PINCON_BASE)

#define PINSEL_BASE_ADDR    0xE002C000
#define PINSEL0        (*(volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00))


/**************************/

/* function in c-file */

void Port_Init()  
{

  LPC_PINCON->PINSEL0 &= ~(3 << 4); //p0.2  

  LPC_PINCON->PINSEL0 |=  (1 << 4); // 

  LPC_PINCON->PINSEL0 &= ~(3 << 6); //p0.3  

  LPC_PINCON->PINSEL0 |=  (1 << 6); // 

  // etc................  
 }

/*******************************************/

  //    ERRORS from PC-Lint    
  //   **********ERROR MESSAGES**************

  #... (volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00))
   uint32_t PINSEL0;
   LPC23.h  153  Error 10: Expecting identifier  

  #... BASE_ADDR + 0x00))  
   uint32_t PINSEL0;
   LPC23.h  153  Error 102: Illegal parameter specification  

  #... BASE_ADDR + 0x00))
   uint32_t PINSEL0;
   LPC23.h  153  Error 10: Expecting ';'
like image 954
user1235613 Avatar asked Aug 25 '26 16:08

user1235613


1 Answers

An excerpt from the PC-lint FAQ:

  1. How do I tell lint not to complain about my compiler headers?

    Lint uses the label of "library" header to designate those headers over which a programmer has no control (such as compiler headers). By default all #includes from a foreign directory, or enclosed within < > , are considered "library." This can be modified through the use of the +libclass option, and further fine-tuned with the +/-libdir and +/-libh options.
    You can then use the -wlib , -elib and -elibsym options to control just those messages being emitted from library headers. Compiler options files distributed with PC-lint usually contain a -wlib(1) option which limits lint output from library headers to errors only (suppressing warning and informational messages).

I guess, that should fit your needs. If not, a minimal example that reproduce your warnings would be nice; the stuff above riddles me, since the #define of PINSEL0 is after its use as identifier in the struct.

like image 112
Matthias Avatar answered Aug 28 '26 06:08

Matthias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!