0

I am trying to port windows code into Linux, and it is failing with the following error.

Below is the snippet for the code.

#include <stdio.h>
#include <stdint.h>
#include <wchar.h>

#define FW_VERSION_STRING_SIZE                 8 // Characters including null.
typedef wchar_t WCHAR;

typedef union _FW_VERSION
{
    uint16_t w;
    struct
    {
        uint8_t rev      : 4;
        uint8_t build    : 4;
        uint8_t minor    : 4;
        uint8_t major    : 4;
    } nib;

} FW_VERSION;


typedef struct _FWV
{
       FW_VERSION fwv;                       // version
       WCHAR      s[FW_VERSION_STRING_SIZE]; // string
} FWV;



int main()
{
    struct
    {
        FWV lat = {0}; // latest
        FWV prv ; // previous
        FWV cur; // current
    } suFwVersions;    
}

I am getting the below error.

cc     /tmp/hello.c   -o /tmp/hello
/tmp/hello.c: In function ‘main’:
/tmp/hello.c:34:17: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
FWV lat = {0}; // latest
        ^
make: *** [/tmp/hello]
Error 1

Is the syntax wrong in Linux, as it succesfully builds in Windows. Gcc version in Linux is 7.3.1

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
md.jamal
  • 4,067
  • 8
  • 45
  • 108

0 Answers0