Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

HELP: Compiling a file that includes nixnet.h with C99 extensions doesn't work

I'm kind of surprised by this.  If I compile ANY of the xnet examples that include nixnet.h with "Build with C99 extensions" enabled, nixnet.h will not compile with the following error:

 

"Types based on variable length arrays are illegal in structs or unions".

 

Why is this?  How is it that the new XNET API isn't able to compile with C99 extensions?

 

Given that I've used some C99 extensions in other parts of my code, I'm now stuck.  If I have to back out those changes, it requires more time to rewrite code that is otherwise working fine.

Message Edited by KavehV on 04-08-2010 04:20 PM
0 Kudos
Message 1 of 6
(7,297 Views)

Does the warning indicate a line number?

What compiler are you using? 

 

I just tried to compile in a gcc version with -std=c99 and I did not get this error. 

0 Kudos
Message 2 of 6
(7,280 Views)

I am guessing that you are using CVI... for a workaround, you can edit the nixnet.h file and replace lines 1889-1901 which are:

 

typedef nxFrameFixed_t(8) nxFrameCAN_t;
typedef nxFrameFixed_t(8) nxFrameLIN_t;
typedef nxFrameFixed_t(1) nxFrameVar_t;

 

with 

 

typedef struct nxFrameCAN_t

{
   nxTimestamp_t Timestamp;
   u32           Identifier;
   u8            Type;
   u8            Flags;
   u8            Info;
   u8            PayloadLength;
   u8            Payload[8];
} nxFrameCAN_t;


typedef struct nxFrameLIN_t

{
   nxTimestamp_t Timestamp;
   u32           Identifier;
   u8            Type;
   u8            Flags;
   u8            Info;
   u8            PayloadLength;
   u8            Payload[8];
}
nxFrameLIN_t;

 

typedef struct nxFrameVar_t

{
   nxTimestamp_t Timestamp;
   u32           Identifier;
   u8            Type;
   u8            Flags;
   u8            Info;
   u8            PayloadLength;
   u8            Payload[8];
} nxFrameVar_t;

 

Message Edited by GPIB Guru on 04-09-2010 09:26 AM
Message 3 of 6
(7,269 Views)

If you are using NI-XNET 1.0 (my prior information was for 1.1), then the lines are 1614 and 1615 and you would replace them with 

 

typedef struct nxFrameCAN_t

{
   nxTimestamp_t Timestamp;
   u32           Identifier;
   u8            Type;
   u8            Flags;
   u8            Info;
   u8            PayloadLength;
   u8            Payload[8];
} nxFrameCAN_t;

typedef struct nxFrameVar_t

{
   nxTimestamp_t Timestamp;
   u32           Identifier;
   u8            Type;
   u8            Flags;
   u8            Info;
   u8            PayloadLength;
   u8            Payload[8];
} nxFrameVar_t;

Message Edited by GPIB Guru on 04-09-2010 09:25 AM
0 Kudos
Message 4 of 6
(7,266 Views)
I'm using CVI 2009.  I found that this is apparently a bug with CVI 2009 compiler.  I haven't been told when a fix is expected though.
Message Edited by KavehV on 04-09-2010 11:28 AM
0 Kudos
Message 5 of 6
(7,250 Views)
Yes - but if you make my changes, they should get you working.
Message 6 of 6
(7,242 Views)