Przyjrzałem się wcześniejszym pytaniom, ale nadal nie byłem zadowolony, dlatego zamieszczam to. Próbowałem skompilować kod C++ napisany przez kogoś innego.Błąd C++: oczekiwane wyrażenie pierwotne przed "." Tokenem
/*
file1.h
*/
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
struct
{
unsigned member1;
unsigned member2;
} str1;
struct
{
unsigned member3;
unsigned member4;
} str2;
struct
{
unsigned member5;
unsigned member6;
} str3;
} CONFIG_T;
/*
file1.c
*/
CONFIG_T cfg =
{
.str1 = { 0x01, 0x02 },
.str2 = { 0x03, 0x04 },
.str3 = { 0x05, 0x06 }
};
W komplecie ze std C++ 11 i otrzymuję poniżej błędu. Dlaczego '.' został użyty w kodzie podczas przypisywania wartości?
home $$ g++ -c -std=gnu++0x initialze_list.cpp
initialze_list.cpp:34: error: expected primary-expression before ‘.’ token
initialze_list.cpp:35: error: expected primary-expression before ‘.’ token
initialze_list.cpp:36: error: expected primary-expression before ‘.’ token
Nie mogłem zrozumieć przyczyny błędu. Proszę pomóż.
które linie są numer 34,35,36? –
Otrzymałeś kod C, a nie C++. Spróbuj kompilatora C. –
Nie jesteś pierwszą osobą, która ma ten problem: http://stackoverflow.com/q/855996/1025391 – moooeeeep