This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/MSP432P401R: Problem with a structure declaration

Part Number: MSP432P401R

Tool/software: TI C/C++ Compiler

Hello! I'm trying to integrate the driver for W5500 Ethernet chip with my code on MSP432 controller, in Code Composer Studio 7 with latest updates. The driver can be found on GitHub. The problem is that the program will not compile because of a struct declaration in Ethernet/wizchip_conf.h. This is the declaration:

typedef struct __WIZCHIP
{
   uint16_t  if_mode;               ///< host interface mode
   uint8_t   id[6];                 ///< @b WIZCHIP ID such as @b 5100, @b 5200, @b 5500, and so on.
   /**
    * The set of critical section callback func.
    */
   struct _CRIS
   {
      void (*_enter)  (void);       ///< crtical section enter 
      void (*_exit) (void);         ///< critial section exit  
   }CRIS;  
   /**
    *  The set of @ref \_WIZCHIP_ select control callback func.
    */
   struct _CS
   {
      void (*_select)  (void);      ///< @ref \_WIZCHIP_ selected
      void (*_deselect)(void);      ///< @ref \_WIZCHIP_ deselected
   }CS;
   /**
    * The set of interface IO callback func.
    */
   union _IF
   {	 
      /**
       * For BUS interface IO
       */
      //M20156501 : Modify the function name for integrating with W5300
      //struct
      //{
      //   uint8_t  (*_read_byte)  (uint32_t AddrSel);
      //   void     (*_write_byte) (uint32_t AddrSel, uint8_t wb);
      //}BUS;      
      struct
      {
         iodata_t  (*_read_data)   (uint32_t AddrSel);
         void      (*_write_data)  (uint32_t AddrSel, iodata_t wb);
      }BUS;      

      /**
       * For SPI interface IO
       */
      struct
      {
         uint8_t (*_read_byte)   (void);
         void    (*_write_byte)  (uint8_t wb);
         void    (*_read_burst)  (uint8_t* pBuf, uint16_t len);
         void    (*_write_burst) (uint8_t* pBuf, uint16_t len);
      }SPI;
      // To be added
      //
   }IF;
}_WIZCHIP;

On the line "   }CS;" I get the following errors:

#170 a function type is not allowed here
#18 expected a ")"
#80 expected a type specifier

 

Does anybody know how to resolve this problem?

  • Unfortunately, I am unable to reproduce the problem.  I had to guess at a few details, and I'm sure I guessed wrong.  Please supply a test case as described in the article How to Submit a Compiler Test Case.  

    Thanks and regards,

    -George

  • I have attached the preprocessed source file, the build log and the project. I'm using the TI v16.9.3.LTS compiler.

    I hope you will provide a solution. Thank you!

    wizchip_conf.pp.txt

    **** Build of configuration Debug for project test ****
    
    "C:\\ti\\ccs710\\ccsv7\\utils\\bin\\gmake" -k -j 2 "W5500 Ethernet Chip/Ethernet/wizchip_conf.obj" -O 
    'Building file: ../W5500 Ethernet Chip/Ethernet/wizchip_conf.c'
    'Invoking: MSP432 Compiler'
    "C:/ti/ccs710/ccsv7/tools/compiler/ti-cgt-arm_16.9.3.LTS/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 -me --include_path="C:/Users/Cristi/Desktop/test" --include_path="C:/ti/simplelink_msp432_sdk_1_40_00_28/source" --include_path="C:/ti/simplelink_msp432_sdk_1_40_00_28/source/third_party/CMSIS/Include" --include_path="C:/ti/ccs710/ccsv7/tools/compiler/ti-cgt-arm_16.9.3.LTS/include" --include_path="C:/Users/Cristi/Desktop/test/W5500 Ethernet Chip/Internet/MQTT/MQTTPacket/src/" --include_path="C:/Users/Cristi/Desktop/test/W5500 Ethernet Chip/Ethernet/" --include_path="C:/Users/Cristi/Desktop/test/W5500 Ethernet Chip/Ethernet/W5500/" --advice:power="all" --advice:power_severity=remark --define=__MSP432P401R__ -g --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_warning=255 --diag_wrap=off --display_error_number --gen_func_subsections=on --obj_directory="W5500 Ethernet Chip/Ethernet"  "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c"
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 218: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 246: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 263: remark #1527-D: (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 432: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 430: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 436: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 453: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 451: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 458: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 505: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 517: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 518: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 570: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 571: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 620: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 623: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 631: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 633: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 635: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 641: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 643: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 648: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 650: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 708: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 710: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 712: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    "../W5500 Ethernet Chip/Ethernet/wizchip_conf.c", line 764: remark #2623-D: (ULP 5.4) Detected an assignment to a type with size less than int. To avoid unnecessary sign extension, use int-sized types for local varaibles and convert to smaller types for static storage.
    'Finished building: ../W5500 Ethernet Chip/Ethernet/wizchip_conf.c'
    ' '
    
    **** Build Finished ****
    

    0310.test.zip

  • I understand what happened.  I cannot tell you the best way to fix it.  I had to use the project to find it.

    The problem happens when the source file ExtensionManager.c is built.  It may happen with other files too.  But this is the one I focused on.

    This file includes many other files.  By using the option --preproc_includes, I am able to see this ...

    C:/Userdata/mytemp/wizchip_test/Extensions/ExtensionManager.h
     C:/ti/simplelink_msp432_sdk_1_30_00_40/source/ti/devices/msp432p4xx/driverlib/driverlib.h
      C:/ti/simplelink_msp432_sdk_1_30_00_40/source/ti/devices/msp432p4xx/driverlib/adc14.h
       C:/ti_ccs62/ccsv6/tools/compiler/ti-cgt-arm_16.9.3.LTS/include/stdint.h
       C:/ti/simplelink_msp432_sdk_1_30_00_40/source/ti/devices/msp432p4xx/inc/msp.h
        C:\ti\simplelink_msp432_sdk_1_30_00_40\source\ti\devices\msp432p4xx\inc\msp432p401r.h

    That is just the first few lines.  Later on this appears ...

     C:\Userdata\mytemp\wizchip_test\Extensions\../W5500 Ethernet Chip/WIZ5500.h
      C:/Userdata/mytemp/wizchip_test/W5500 Ethernet Chip/Ethernet/wizchip_conf.h
    

    The file msp432p401r.h has this source line ...

    #define CS                               ((CS_Type *) CS_BASE)

    The file wizchip_conf.h is processed later.  It has these source lines ...

       struct _CS
       {
          void (*_select)  (void);      ///< @ref \_WIZCHIP_ selected
          void (*_deselect)(void);      ///< @ref \_WIZCHIP_ deselected
       }CS;

    Because of the #define CS, that last source line expands to ...

       }((CS_Type *) (((uint32_t)0x40000000) +0x00010400));

    And that is not legal C code.  

    I found all this by using option --gen_preprocessor_listing to create a .rl file.  This file shows all the details of what occurs before and after preprocessing.  You can read about all the options I mention in this post in the ARM compiler manual.

    While I can think of possible solutions, I'm not sure which is best in your case.  That requires knowledge of those SimpleLink header files that I do not have.  I recommend you start a new thread in the MSP device forum.  Or, if you prefer, I can move this thread into that forum.

    Thanks and regards,

    -George

  • Please move the thread to the other forum. A solution would be to (refactor) rename the structure from the wiznet file. I've renamed CS to CSWiz (and all its references) and it works.

**Attention** This is a public forum