J
junky_fellow
guys,
I have a code that has to be compiled with C and C++ compiler both.
WIth C, I don't get any error but with C++, I am getting following
error.
error C2059: syntax error : '{'
Here is the code:
--------------------------------------------------------
#include <stdio.h>
#include <string.h>
typedef unsigned char uint8;
typedef struct {
uint8 b[16];
} efiGuid;
#define EFI_GUID(a, b, c, d, e0, e1, e2, e3, e4, e5) \
((efiGuid) \
{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) &
0xff, \
(b) & 0xff, ((b) >> 8) & 0xff, \
(c) & 0xff, ((c) >> 8) & 0xff, \
(d) & 0xff, ((d) >> 8) & 0xff, \
(e0), (e1), (e2), (e3), (e4), (e5) }})
#define GUID_ABC \
EFI_GUID(0x00000000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00,
0x00, 0x00, 0
x00)
#define GUID_XYZ \
EFI_GUID(0xc12a7328, 0xf81f, 0x11d2, 0xba4b, 0x00, 0xa0, 0xc9,
0x3e, 0xc9, 0
x3b)
int main(void)
{
typedef struct {
unsigned int time_low;
unsigned short time_mid;
unsigned short time_hi_and_version;
unsigned char clock_seq_hi_and_reserved;
unsigned char clock_seq_low;
unsigned char node[6];
} efi_guid_t;
if (memcmp(&efiguid, &GUID_ABC, sizeof(efiGuid)) == 0) { <====
error on this line
printf("ABC\n");
} else if (memcmp(&efiguid, &GUID_XYZ, sizeof(efiGuid)) == 0)
{ <=== error on this line
printf("XYZ\n");
} else
printf("unknow\n");
}
Any idea what is the reason the comilation fails on visual c++
compiler.
thanks for any help.
I have a code that has to be compiled with C and C++ compiler both.
WIth C, I don't get any error but with C++, I am getting following
error.
error C2059: syntax error : '{'
Here is the code:
--------------------------------------------------------
#include <stdio.h>
#include <string.h>
typedef unsigned char uint8;
typedef struct {
uint8 b[16];
} efiGuid;
#define EFI_GUID(a, b, c, d, e0, e1, e2, e3, e4, e5) \
((efiGuid) \
{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) &
0xff, \
(b) & 0xff, ((b) >> 8) & 0xff, \
(c) & 0xff, ((c) >> 8) & 0xff, \
(d) & 0xff, ((d) >> 8) & 0xff, \
(e0), (e1), (e2), (e3), (e4), (e5) }})
#define GUID_ABC \
EFI_GUID(0x00000000, 0x0000, 0x0000, 0x0000, 0x00, 0x00, 0x00,
0x00, 0x00, 0
x00)
#define GUID_XYZ \
EFI_GUID(0xc12a7328, 0xf81f, 0x11d2, 0xba4b, 0x00, 0xa0, 0xc9,
0x3e, 0xc9, 0
x3b)
int main(void)
{
typedef struct {
unsigned int time_low;
unsigned short time_mid;
unsigned short time_hi_and_version;
unsigned char clock_seq_hi_and_reserved;
unsigned char clock_seq_low;
unsigned char node[6];
} efi_guid_t;
if (memcmp(&efiguid, &GUID_ABC, sizeof(efiGuid)) == 0) { <====
error on this line
printf("ABC\n");
} else if (memcmp(&efiguid, &GUID_XYZ, sizeof(efiGuid)) == 0)
{ <=== error on this line
printf("XYZ\n");
} else
printf("unknow\n");
}
Any idea what is the reason the comilation fails on visual c++
compiler.
thanks for any help.