I am working on a project that parses a text file thats suppose to be a simple coded program. The problem is that when I try to complile the program I get this error:
In file included from driver.c:10:
parser.c: In function ‘Statement’:
parser.c:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:153: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:159: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:167: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:176: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:185: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:194: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:201: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:209: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
driver.c:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
driver.c:50: error: old-style parameter declarations in prototyped function definition
driver.c:50: error: expected ‘{’ at end of input
Im not familiar with this error and not sure how to fix it.
Here is my parser.c file which the error is happening in:
#include <stdio.h>
#include <stdlib.h>
#include "parser.h"
AST_NODE* Program(AST_NODE* node);
AST_NODE* Statement(AST_NODE* node)
AST_NODE* AssignStmt(AST_NODE* node);
AST_NODE* Print(AST_NODE *node);
AST_NODE* Repeat(AST_NODE* node);
AST_NODE* Exp(AST_NODE* node);
AST_NODE* Factor(AST_NODE* node);
AST_NODE* Term(AST_NODE* node);
AST_NODE* parser(TOKEN* token,AST_NODE* node, FILE* input_file)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
if(token->type == Id)
{
temp-> tok = token;
node -> child1 = temp;
return node
}else
if(token->type == keyword)
{
if(strcmp(node->attribute, "print") == 0)
{
temp -> type = print;
node -> child1 = temp;
return node;
}
else if(strcmp(node->attribute, "repeat") == 0)
{
temp -> type = repeat;
node -> child1 = temp;
return node;
}
return node->prev;
}else
if(token->type == num)
{
temp->type = factor;
temp->tok = token;
AST_NODE temp2 = Exp(Term(temp));
node-> child3 = temp2
return node;//back to ID->term->exp then to either print repeat or assignment
}else
if(token->type == addOp)
{
temp-> tok = token;
node-> child2 = temp;
return node;
}else
if(token->type == multOp)
{
temp-> tok = token;
node-> child2 = temp;
return node;
}else
if(token->type == assignment)
{
temp->type = assignStmt;
temp->tok = token;
node->child2 = temp;
return node;
}else
if(token->type == semicolon)
{
temp-> type = assignStmt;
temp-> tok = token;
if(node->type == keyword)
{
node->child3 = temp;
}else
{
node->child4 = temp;
}
return node;
}else
if(token->type == lparen)
{
temp -> tok = token;
if(node->type == repeat)
node->child2 = temp;
else
node->child1 = temp;
return node = node->prev;
}else
if(token->type == rparen)
{
temp -> tok = token;
if(node->type == repeat)
node->child4 = temp;
else
node->child3 = temp;
return node;
}else if(token->type == newLine)
{
while(node->type != program)
{
node = node->prev;
}
return node;
}else{
if(token->type == Id)
{
AST_NODE temp2 = AssignStmt(Program(node));
temp->type = Id;
temp->tok = token
temp->prev = temp2;
temp2-> child1 = temp;
return temp2;
}else if(strcmp(token->attribute,"print"))
{
AST_NODE temp2 = Print(Program(node));
temp->type = print;
temp->tok = token
temp->prev = temp2;
temp2-> child1 = temp;
return temp2;
}else if(strcmp(token->attribute,"repeat"))
{
AST_NODE temp2 = Repeat(Program(node));
temp->type = repeat;
temp->tok = token
temp->prev = temp2;
temp2-> child1 = temp;
return temp2;
}
printf("error");
return NULL;
}
}
AST_NODE* Program(AST_NODE* node)
{
node->type = program;
Statement(node);
return node;
}
AST_NODE* Statement(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp-> type = statement;
temp-> prev = node;
node->child1-> temp;
return temp;
}
AST_NODE* AssignStmt(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = assignStmt;
temp-> prev = node;
node->child1-> temp;
return temp;
}
AST_NODE* Print(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = print;
temp-> prev = node;
node->child1-> temp;
return node;
}
AST_NODE* Repeat(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = repeat;
temp-> prev = node;
node->child1-> temp;
return node;
}
AST_NODE* Exp(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = exp;
temp->child1-> node;
return temp;
}
AST_NODE* factor(AST_NODE* node)
{
AST_NODE Temp = malloc(sizeof(AST_NODE*));
temp->type = factor;
node->child1-> temp;
return temp;
}
AST_NODE* Term(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = term;
temp->child1-> node;
return temp;
}
Here is my driver.c file where I am also getting the error «old-style parameter declarations in prototyped function definition expected ‘{‘ at end of input». This also I am very unfamiliar with.
#include <stdio.h>
#include "parser.c"
#include "parser.h"
AST_NODE* parser(TOKEN* token,AST_NODE node, FILE *input_file);
int main(void)
{
TREE *current = 0;
FILE *input_file = fopen("test.txt", "r");
TOKEN *token = (TOKEN*) malloc(sizeof(TOKEN));
TOKEN *tok = (TOKEN*) malloc(sizeof(TOKEN));
AST_NODE* node = malloc(sizeof(AST_NODE));
while(!feof(input_file))
{
token = scan(input_file);
if(token->type != null)
{
parser(token,node,input_file);
printf("%s", token->attribute);
if(token->checkR == ';')
{
tok->type = semicolon;
tok->attribute = ";";
parser(tok,node,input_file);
}if(token->checkR == ')')
{
tok->type = rparen;
tok->attribute = ")";
parser(tok,node,input_file);
}
}
}
fclose(input_file);
return 0;
}
Here is my parser.h file where I declare my TOKEN and my AST_NODE to create my tree and form my tokens to fill the tree.
#ifndef _parser_h
#define _parser_h
typedef enum token_type
{
null,
Id,
keyword,
num,
addOp,
multOp,
assignment,
semicolon,
lparen,
rparen,
newLine
}TOKEN_TYPE;
typedef struct token{
int type;
char *attribute;
char checkR;
}TOKEN;
typedef enum node_type
{
program,
statement,
assignStmt,
print,
repeat,
exp,
factor,
term
}NODE_TYPE;
typedef struct ast_node{
NODE_TYPE type;
TOKEN *tok;
struct AST_NODE *prev;
struct AST_NODE *child1;
struct AST_NODE *child2;
struct AST_NODE *child3;
struct AST_NODE *child4;
struct AST_NODE *child5;
}AST_NODE;
#endif
There is one more file called scanner.c but I know its working perfectly because I have tested it in all the possible inputs and got no problems.
If anyone could help I would appreciate it very much.
Could not able to solve this..
I am implementing a queue. After writing the complete code I had the error listed below:
expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
Then I wrote a simple program, but same problem persists. Couldn’t able to understand how to solve this. I have looked into solutions in stackoverflow.com and google.com
a lot but still couldn’t able to solve this.Please help.
I would like to initialize globally
Q.front = Q.rear = Any value
#include <stdio.h>
#include <stdlib.h>
struct Queue
{
int front, rear;
int queue[10] ;
};
struct Queue Q;
Q.front = 0;
Q.rear = 0;
int main()
{
return 0;
}
I159
29.5k31 gold badges97 silver badges132 bronze badges
asked Apr 25, 2012 at 7:09
0
Q.front = 0;
is not a simple initializer, it is executable code; it cannot occur outside of a function. Use a proper initializer for Q
.
struct Queue Q = {0, 0};
or with named initializer syntax (not available in all compilers, and as yet only in C):
struct Queue Q = {.front = 0, .rear = 0};
answered Apr 25, 2012 at 7:14
geekosaurgeekosaur
58.8k11 gold badges123 silver badges114 bronze badges
0
You can’t initialize variable using Q.front = 0; Q.rear = 0;
in global scope. Those statements should be inside main
in your case.
answered Apr 25, 2012 at 7:14
As @Naveen said you can’t assign to a member of a struct that is in global scope. Depending on the version of C though you could do this:
struct Queue q = {0,0};
or
struct Queue q = {.front = 0, .rear = 0 };
answered Apr 25, 2012 at 7:17
WillWill
4,5651 gold badge26 silver badges48 bronze badges
Home »
C programs »
C common errors programs
Here, we will learn why an Error: expected ‘=’, ‘,’, ‘,’ ‘asm’ or ‘ _attribute_’ before ‘<‘ token is occurred and how to fix it in C programming language?
Submitted by IncludeHelp, on September 11, 2018
A very common error in C programming language, it occurs when # is not used before the include.
As we know that #include is a preprocessor directive and it is used to include a header file’s code to the program. But, include is nothing without #, it is not valid and it cannot be used to include a header file in the program.
Example:
include <stdio.h> int main(void) { printf("Hello world!"); return 0; }
Output
prog.c:1:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token include <stdio.h> ^
How to fix?
To fix this error — use #include.
Correct code:
#include <stdio.h> int main(void) { printf("Hello world!"); return 0; }
Output
Hello world!
C Common Errors Programs »
0
0
Пытаюсь перевести небольшую программу с с++ на читый с. С g++ все компилируется и работает, с gcc выдает ошибку:
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
Код выглядит примерно так:
struct my_structure;
my_structure* get_my_structure(char* param);
Ошибка ругается на 2ю строку. Гугл ничего внятного не говорит. Не пойму, что здесь не так.
gcc (GCC) 4.2.1 (SUSE Linux)
- Ссылка
I am working on a project that parses a text file thats suppose to be a simple coded program. The problem is that when I try to complile the program I get this error:
In file included from driver.c:10:
parser.c: In function ‘Statement’:
parser.c:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:153: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:159: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:167: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:176: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:185: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:194: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:201: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
parser.c:209: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
driver.c:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
driver.c:50: error: old-style parameter declarations in prototyped function definition
driver.c:50: error: expected ‘{’ at end of input
Im not familiar with this error and not sure how to fix it.
Here is my parser.c file which the error is happening in:
#include <stdio.h>
#include <stdlib.h>
#include "parser.h"
AST_NODE* Program(AST_NODE* node);
AST_NODE* Statement(AST_NODE* node)
AST_NODE* AssignStmt(AST_NODE* node);
AST_NODE* Print(AST_NODE *node);
AST_NODE* Repeat(AST_NODE* node);
AST_NODE* Exp(AST_NODE* node);
AST_NODE* Factor(AST_NODE* node);
AST_NODE* Term(AST_NODE* node);
AST_NODE* parser(TOKEN* token,AST_NODE* node, FILE* input_file)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
if(token->type == Id)
{
temp-> tok = token;
node -> child1 = temp;
return node
}else
if(token->type == keyword)
{
if(strcmp(node->attribute, "print") == 0)
{
temp -> type = print;
node -> child1 = temp;
return node;
}
else if(strcmp(node->attribute, "repeat") == 0)
{
temp -> type = repeat;
node -> child1 = temp;
return node;
}
return node->prev;
}else
if(token->type == num)
{
temp->type = factor;
temp->tok = token;
AST_NODE temp2 = Exp(Term(temp));
node-> child3 = temp2
return node;//back to ID->term->exp then to either print repeat or assignment
}else
if(token->type == addOp)
{
temp-> tok = token;
node-> child2 = temp;
return node;
}else
if(token->type == multOp)
{
temp-> tok = token;
node-> child2 = temp;
return node;
}else
if(token->type == assignment)
{
temp->type = assignStmt;
temp->tok = token;
node->child2 = temp;
return node;
}else
if(token->type == semicolon)
{
temp-> type = assignStmt;
temp-> tok = token;
if(node->type == keyword)
{
node->child3 = temp;
}else
{
node->child4 = temp;
}
return node;
}else
if(token->type == lparen)
{
temp -> tok = token;
if(node->type == repeat)
node->child2 = temp;
else
node->child1 = temp;
return node = node->prev;
}else
if(token->type == rparen)
{
temp -> tok = token;
if(node->type == repeat)
node->child4 = temp;
else
node->child3 = temp;
return node;
}else if(token->type == newLine)
{
while(node->type != program)
{
node = node->prev;
}
return node;
}else{
if(token->type == Id)
{
AST_NODE temp2 = AssignStmt(Program(node));
temp->type = Id;
temp->tok = token
temp->prev = temp2;
temp2-> child1 = temp;
return temp2;
}else if(strcmp(token->attribute,"print"))
{
AST_NODE temp2 = Print(Program(node));
temp->type = print;
temp->tok = token
temp->prev = temp2;
temp2-> child1 = temp;
return temp2;
}else if(strcmp(token->attribute,"repeat"))
{
AST_NODE temp2 = Repeat(Program(node));
temp->type = repeat;
temp->tok = token
temp->prev = temp2;
temp2-> child1 = temp;
return temp2;
}
printf("error");
return NULL;
}
}
AST_NODE* Program(AST_NODE* node)
{
node->type = program;
Statement(node);
return node;
}
AST_NODE* Statement(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp-> type = statement;
temp-> prev = node;
node->child1-> temp;
return temp;
}
AST_NODE* AssignStmt(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = assignStmt;
temp-> prev = node;
node->child1-> temp;
return temp;
}
AST_NODE* Print(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = print;
temp-> prev = node;
node->child1-> temp;
return node;
}
AST_NODE* Repeat(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = repeat;
temp-> prev = node;
node->child1-> temp;
return node;
}
AST_NODE* Exp(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = exp;
temp->child1-> node;
return temp;
}
AST_NODE* factor(AST_NODE* node)
{
AST_NODE Temp = malloc(sizeof(AST_NODE*));
temp->type = factor;
node->child1-> temp;
return temp;
}
AST_NODE* Term(AST_NODE* node)
{
AST_NODE temp = malloc(sizeof(AST_NODE*));
temp->type = term;
temp->child1-> node;
return temp;
}
Here is my driver.c file where I am also getting the error «old-style parameter declarations in prototyped function definition expected ‘{‘ at end of input». This also I am very unfamiliar with.
#include <stdio.h>
#include "parser.c"
#include "parser.h"
AST_NODE* parser(TOKEN* token,AST_NODE node, FILE *input_file);
int main(void)
{
TREE *current = 0;
FILE *input_file = fopen("test.txt", "r");
TOKEN *token = (TOKEN*) malloc(sizeof(TOKEN));
TOKEN *tok = (TOKEN*) malloc(sizeof(TOKEN));
AST_NODE* node = malloc(sizeof(AST_NODE));
while(!feof(input_file))
{
token = scan(input_file);
if(token->type != null)
{
parser(token,node,input_file);
printf("%s", token->attribute);
if(token->checkR == ';')
{
tok->type = semicolon;
tok->attribute = ";";
parser(tok,node,input_file);
}if(token->checkR == ')')
{
tok->type = rparen;
tok->attribute = ")";
parser(tok,node,input_file);
}
}
}
fclose(input_file);
return 0;
}
Here is my parser.h file where I declare my TOKEN and my AST_NODE to create my tree and form my tokens to fill the tree.
#ifndef _parser_h
#define _parser_h
typedef enum token_type
{
null,
Id,
keyword,
num,
addOp,
multOp,
assignment,
semicolon,
lparen,
rparen,
newLine
}TOKEN_TYPE;
typedef struct token{
int type;
char *attribute;
char checkR;
}TOKEN;
typedef enum node_type
{
program,
statement,
assignStmt,
print,
repeat,
exp,
factor,
term
}NODE_TYPE;
typedef struct ast_node{
NODE_TYPE type;
TOKEN *tok;
struct AST_NODE *prev;
struct AST_NODE *child1;
struct AST_NODE *child2;
struct AST_NODE *child3;
struct AST_NODE *child4;
struct AST_NODE *child5;
}AST_NODE;
#endif
There is one more file called scanner.c but I know its working perfectly because I have tested it in all the possible inputs and got no problems.
If anyone could help I would appreciate it very much.
Home »
C programs »
C common errors programs
Here, we will learn why an Error: expected ‘=’, ‘,’, ‘,’ ‘asm’ or ‘ _attribute_’ before ‘<‘ token is occurred and how to fix it in C programming language?
Submitted by IncludeHelp, on September 11, 2018
A very common error in C programming language, it occurs when # is not used before the include.
As we know that #include is a preprocessor directive and it is used to include a header file’s code to the program. But, include is nothing without #, it is not valid and it cannot be used to include a header file in the program.
Example:
include <stdio.h> int main(void) { printf("Hello world!"); return 0; }
Output
prog.c:1:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token include <stdio.h> ^
How to fix?
To fix this error — use #include.
Correct code:
#include <stdio.h> int main(void) { printf("Hello world!"); return 0; }
Output
Hello world!
C Common Errors Programs »
У меня есть следующие декларации
FILE *fptr;
FILE *optr;
в algo.h у меня есть главный файл main.c, который открывает эти файлы. Я получаю указанную выше ошибку, если помещаю объявления в файл заголовка. Если я помещу его в main.c, я получаю несколько ошибок определения, например
srcmain.o:main.c:(.bss+0xc88): multiple definition of rcount'
condi'
srcnew_algo.o:new_algo.c:(.bss+0xc88): first defined here
srcmain.o:main.c:(.bss+0xc8c): multiple definition of
srcnew_algo.o:new_algo.c:(.bss+0xc8c): first defined here
4 ответы
Похоже, вы (1) не включили <stdio.h>
где вы используете FILE
, и / или (2) имеют некоторые не-static
исполняемый код или не-extern
определения переменных в ваших заголовках (и / или #include
файл C).
Первый обычно вызывает FILE
не быть определенным (или быть typedef
‘d к типу, который в некоторых случаях не существует). Во втором случае в каждой единице перевода, включающей файл, будет определен материал, что сбивает компоновщик с толку.
Чтобы исправить: (1) #include <stdio.h>
в файле, где FILE
используется, и (2) переместить общие определения из заголовков в файл .c (и / или объявить их как static
or extern
по мере необходимости), и только когда-либо #include
.h файлы.
ответ дан 07 апр.
То, что у вас есть в algo.h, — это определение не декларация. Если у тебя есть ФАЙЛ * fptr; ФАЙЛ * optr; и в исходном, и в заголовочном файле вы объявляете переменные дважды.
Вам потребуется:
алго.ч
extern FILE *fptr;
extern FILE *optr;
алго.с
FILE *fptr;
FILE *optr;
ответ дан 07 апр.
Похоже, вы не включаете stdio. Добавлять
#include <stdio.h>
в вашем заголовочном файле над этими объявлениями.
Ошибки компоновщика не имеют ничего общего с FILE
опубликованные вами переменные.
В вашем источнике есть две переменные с именем rcount
и condi
, который, согласно компоновщику, определен в обоих ваших исходных файлах. Причина, я полагаю, в том, что вы определяете эти переменные в файле заголовка, который включен в оба исходных файла. Некоторые старые компиляторы до сих пор не справляются с этим.
Создан 22 ноя.
Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками
c
file-io
header-files
or задайте свой вопрос.
- Печать
Страницы: [1] 2 Все Вниз
Тема: Не компилируется ни одна программа (Прочитано 1707 раз)
0 Пользователей и 1 Гость просматривают эту тему.
Nereus
При компиляции GCC выдает такую ошибку :
имя_программы.c:1:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
« Последнее редактирование: 24 Июня 2011, 13:15:24 от Nereus »
Sharabdin
скорее всего ты копировал код программы с браузера ,и он вставился не правильно .
Nereus
JEKA_JS
Будет проще, если выложите текст программы.
Nereus
yorik1984
код в студию!
Пользователь решил продолжить мысль 24 Июня 2011, 13:16:19:
как компилируется?
Nereus
Я же сказал, что ни одна программа не компилируется! Все время выдается одна ошибка. Смысл приводить код?
arrecck
yorik1984
Пользователь решил продолжить мысль 24 Июня 2011, 13:29:54:
Я же сказал, что ни одна программа не компилируется! Все время выдается одна ошибка. Смысл приводить код?
какой командой компилируется?
daniil.r
Я же сказал, что ни одна программа не компилируется! Все время выдается одна ошибка. Смысл приводить код?
По вашему ошибка вроде «error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token» может быть уникальна для каждой программы? Приведенная вами ошибка указывает на ошибки непосредственно в коде. Соответственно, если не хотите выкладывать ее исходники, решайте проблему самостоятельно.
P.S. Вы случаем не пытаетесь скомпилять питоновский (или какой-либо другой отличный от Си) код с помощь gcc?
Nereus
Любую хрень можно написать — одна и та же ошибка. Сам не верю.
Вы меня совсем за дебила держите? Зачем я буду кормить питоном GCC? Короче я понял, легче снести всю систему на хер.
Что-то меня сегодня на хер пробило, на хер…
« Последнее редактирование: 24 Июня 2011, 13:42:09 от Nereus »
daniil.r
Любую хрень можно написать — одна и та же ошибка. Сам не верю.
Вы меня совсем за дебила держите. Зачем я буду кормить питоном GCC? Короче я понял, легче снести всю систему на хер.
Что-то меня сегодня на хер пробило, на хер…
Может хотя бы команду предоставите, которой компиляете, не?
Lifewalker
Вы меня совсем за дебила держите?
Сам сказал и вообще-то да, держим.
Код покажи, команду компиляции покажи и вывод покажи. Тогда может быть перестанем.
Nereus
Забаньте меня админы!
Попей валокордину, готово (c)
« Последнее редактирование: 24 Июня 2011, 14:00:11 от VinnyPooh »
JEKA_JS
Печально
- Печать
Страницы: [1] 2 Все Вверх
Произошла ошибка, когда я загрузил этот код в Arduino Atmega2560. Это файл библиотеки, который я создал для файлов .c в моей программе.
Ошибка:
herkulex.c:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
Слово «класс» выделяется при появлении ошибки, которая находится в файле (код показан ниже)
#ifndef herkulex_lib
#define herkulex_lib
#include <Arduino.h>
#include <Wire.h>
#include<inttypes.h>
class herkulex
{
public:
herkulex();
void hklx_Init(unsigned long ulBaudRate);
void hklx_SendPacket(DrsPacket stPacket);
unsigned char hklx_ucReceivePacket(DrsPacket *pstPacket);
void hklx_RemoveInvalidData(void);
//no private
};
#endif /* HERKULEX_H_ */
Могу ли я узнать, что не так с этим кодом? Спасибо!
2
Решение
Вы компилируете файл C, который содержит C ++. Компилятор C отклоняет синтаксис C ++.
Вместо этого скомпилируйте его как программу на C ++.
6
Другие решения
Разве нет space
здесь отсутствует 😕
#include<inttypes.h>
0
Hello,
I am very very very new to Unix, but experienced in C. I wasn’t sure whether this Message fits the Unix forum (if there’s one), or C. But, since it is a compiling Error, I felt it fits here best.
I did a «make», compilation, to a program called ioquake3. I get these errors. I tried to google them. It seems that these errors are caused by double inclusions, or something of the sort.
I tried endlessly to see how to make the write edits to the code. But, I couldn’t fix it.
Thank you in advance.
Code:
#include <stdio.h> #include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" #ifdef WIN32 #define DEFAULT_CURL_LIB "libcurl-3.dll" #elif defined(MACOS_X) #define DEFAULT_CURL_LIB "libcurl.dylib" #else #define DEFAULT_CURL_LIB "libcurl.so.4" #define ALTERNATE_CURL_LIB "libcurl.so.3" #endif #ifdef USE_LOCAL_HEADERS //#include <../libcurl/curl/curl.h> #else //#include <../libcurl/curl/curl.h> #endif #ifdef USE_CURL_DLOPEN extern char* (*qcurl_version)(void); extern cvar_t *cl_cURLLib; extern CURL* (*qcurl_easy_init)(void); extern CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...); extern CURLcode (*qcurl_easy_perform)(CURL *curl); extern void (*qcurl_easy_cleanup)(CURL *curl); extern CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...); extern void (*qcurl_easy_reset)(CURL *curl); extern const char *(*qcurl_easy_strerror)(CURLcode); extern CURLM* (*qcurl_multi_init)(void); extern CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle, CURL *curl_handle); extern CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle, CURL *curl_handle); extern CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle, fd_set *read_fd_set, fd_set *write_fd_set, fd_set *exc_fd_set, int *max_fd); extern CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle, int *running_handles); extern CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle); extern CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle, int *msgs_in_queue); extern const char *(*qcurl_multi_strerror)(CURLMcode); #else #define qcurl_version curl_version #define qcurl_easy_init curl_easy_init #define qcurl_easy_setopt curl_easy_setopt #define qcurl_easy_perform curl_easy_perform #define qcurl_easy_cleanup curl_easy_cleanup #define qcurl_easy_getinfo curl_easy_getinfo #define qcurl_easy_duphandle curl_easy_duphandle #define qcurl_easy_reset curl_easy_reset #define qcurl_easy_strerror curl_easy_strerror #define qcurl_multi_init curl_multi_init #define qcurl_multi_add_handle curl_multi_add_handle #define qcurl_multi_remove_handle curl_multi_remove_handle #define qcurl_multi_fdset curl_multi_fdset #define qcurl_multi_perform curl_multi_perform #define qcurl_multi_cleanup curl_multi_cleanup #define qcurl_multi_info_read curl_multi_info_read #define qcurl_multi_strerror curl_multi_strerror #endif qboolean CL_cURL_Init( void ); void CL_cURL_Shutdown( void ); void CL_cURL_BeginDownload( const char *localName, const char *remoteURL ); void CL_cURL_PerformDownload( void ); void CL_cURL_Cleanup( void );</stdio.h>
Errors:
make[2]: `build/release-linux-x86_64/ioq3ded.x86_64' is up to date. CC code/client/cl_cgame.c In file included from code/client/cl_cgame.c:24: code/client/client.h:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token code/client/client.h:41: error: expected declaration specifiers or '...' before '*' token code/client/client.h:41: error: expected ')' before '*' token code/client/client.h:42: error: expected declaration specifiers or '...' before '*' token code/client/client.h:42: error: expected ')' before '*' token code/client/client.h:43: error: expected ')' before '*' token code/client/client.h:44: error: expected declaration specifiers or '...' before '*' token code/client/client.h:44: error: expected ')' before '*' token code/client/client.h:45: error: expected ')' before '*' token code/client/client.h:46: warning: parameter names (without types) in function declaration code/client/client.h:48: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token code/client/client.h:49: error: expected declaration specifiers or '...' before '*' token code/client/client.h:49: error: expected ')' before '*' token code/client/client.h:51: error: expected declaration specifiers or '...' before '*' token code/client/client.h:51: error: expected ')' before '*' token code/client/client.h:53: error: expected declaration specifiers or '...' before '*' token code/client/client.h:53: error: expected ')' before '*' token code/client/client.h:58: error: expected declaration specifiers or '...' before '*' token code/client/client.h:58: error: expected ')' before '*' token code/client/client.h:60: error: expected declaration specifiers or '...' before '*' token code/client/client.h:60: error: expected ')' before '*' token code/client/client.h:61: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token code/client/client.h:63: warning: parameter names (without types) in function declaration In file included from code/client/cl_cgame.c:24: code/client/client.h:264: error: expected specifier-qualifier-list before 'CURL' code/client/cl_cgame.c: In function 'CL_GetServerCommand': code/client/cl_cgame.c:276: error: 'clientConnection_t' has no member named 'demoplaying' code/client/cl_cgame.c: In function 'CL_InitCGame': code/client/cl_cgame.c:751: error: 'clientConnection_t' has no member named 'demoplaying' code/client/cl_cgame.c: In function 'CL_CGameRendering': code/client/cl_cgame.c:799: error: 'clientConnection_t' has no member named 'demoplaying' code/client/cl_cgame.c: In function 'CL_AdjustTimeDelta': code/client/cl_cgame.c:834: error: 'clientConnection_t' has no member named 'demoplaying' code/client/cl_cgame.c: In function 'CL_FirstSnapshot': code/client/cl_cgame.c:900: error: 'clientConnection_t' has no member named 'timeDemoBaseTime' code/client/cl_cgame.c:919: error: 'clientConnection_t' has no member named 'speexInitialized' code/client/cl_cgame.c:921: error: 'clientConnection_t' has no member named 'speexEncoderBits' code/client/cl_cgame.c:922: error: 'clientConnection_t' has no member named 'speexEncoderBits' code/client/cl_cgame.c:924: error: 'clientConnection_t' has no member named 'speexEncoder' code/client/cl_cgame.c:926: error: 'clientConnection_t' has no member named 'speexEncoder' code/client/cl_cgame.c:927: error: 'clientConnection_t' has no member named 'speexFrameSize' code/client/cl_cgame.c:928: error: 'clientConnection_t' has no member named 'speexEncoder' code/client/cl_cgame.c:929: error: 'clientConnection_t' has no member named 'speexSampleRate' code/client/cl_cgame.c:931: error: 'clientConnection_t' has no member named 'speexPreprocessor' code/client/cl_cgame.c:931: error: 'clientConnection_t' has no member named 'speexFrameSize' code/client/cl_cgame.c:932: error: 'clientConnection_t' has no member named 'speexSampleRate' code/client/cl_cgame.c:935: error: 'clientConnection_t' has no member named 'speexPreprocessor' code/client/cl_cgame.c:939: error: 'clientConnection_t' has no member named 'speexPreprocessor' code/client/cl_cgame.c:943: error: 'clientConnection_t' has no member named 'speexDecoderBits' code/client/cl_cgame.c:944: error: 'clientConnection_t' has no member named 'speexDecoderBits' code/client/cl_cgame.c:945: error: 'clientConnection_t' has no member named 'speexDecoder' code/client/cl_cgame.c:946: error: 'clientConnection_t' has no member named 'voipIgnore' code/client/cl_cgame.c:947: error: 'clientConnection_t' has no member named 'voipGain' code/client/cl_cgame.c:949: error: 'clientConnection_t' has no member named 'speexInitialized' code/client/cl_cgame.c:950: error: 'clientConnection_t' has no member named 'voipMuteAll' code/client/cl_cgame.c:953: error: 'clientConnection_t' has no member named 'voipTarget1' code/client/cl_cgame.c:953: error: 'clientConnection_t' has no member named 'voipTarget2' code/client/cl_cgame.c:953: error: 'clientConnection_t' has no member named 'voipTarget3' code/client/cl_cgame.c: In function 'CL_SetCGameTime': code/client/cl_cgame.c:969: error: 'clientConnection_t' has no member named 'demoplaying' code/client/cl_cgame.c:972: error: 'clientConnection_t' has no member named 'firstDemoFrameSkipped' code/client/cl_cgame.c:973: error: 'clientConnection_t' has no member named 'firstDemoFrameSkipped' code/client/cl_cgame.c:1006: error: 'clientConnection_t' has no member named 'demoplaying' code/client/cl_cgame.c:1045: error: 'clientConnection_t' has no member named 'demoplaying' code/client/cl_cgame.c:1061: error: 'clientConnection_t' has no member named 'timeDemoStart' code/client/cl_cgame.c:1062: error: 'clientConnection_t' has no member named 'timeDemoStart' code/client/cl_cgame.c:1062: error: 'clientConnection_t' has no member named 'timeDemoLastFrame' code/client/cl_cgame.c:1063: error: 'clientConnection_t' has no member named 'timeDemoMinDuration' code/client/cl_cgame.c:1064: error: 'clientConnection_t' has no member named 'timeDemoMaxDuration' code/client/cl_cgame.c:1067: error: 'clientConnection_t' has no member named 'timeDemoLastFrame' code/client/cl_cgame.c:1068: error: 'clientConnection_t' has no member named 'timeDemoLastFrame' code/client/cl_cgame.c:1071: error: 'clientConnection_t' has no member named 'timeDemoFrames' code/client/cl_cgame.c:1073: error: 'clientConnection_t' has no member named 'timeDemoMaxDuration' code/client/cl_cgame.c:1074: error: 'clientConnection_t' has no member named 'timeDemoMaxDuration' code/client/cl_cgame.c:1076: error: 'clientConnection_t' has no member named 'timeDemoMinDuration' code/client/cl_cgame.c:1077: error: 'clientConnection_t' has no member named 'timeDemoMinDuration' code/client/cl_cgame.c:1083: error: 'clientConnection_t' has no member named 'timeDemoDurations' code/client/cl_cgame.c:1083: error: 'clientConnection_t' has no member named 'timeDemoFrames' code/client/cl_cgame.c:1087: error: 'clientConnection_t' has no member named 'timeDemoFrames' code/client/cl_cgame.c:1088: error: 'clientConnection_t' has no member named 'timeDemoBaseTime' code/client/cl_cgame.c:1088: error: 'clientConnection_t' has no member named 'timeDemoFrames' make[2]: *** [build/release-linux-x86_64/client/cl_cgame.o] Error 1 make[2]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/best_linux_20111012/ioquake3dev_clean' make[1]: *** [targets] Error 2 make[1]: Leaving directory `/r/home7/yasir/minoru/cfe2/yasirTemp/ioquake3dev/best_linux_20111012/ioquake3dev_clean' make: *** [release] Error 2
Language C
Linux
8
Hi
I am using WINAVR compiler for ATMEGA32. While compiling c progam , I am getting the error
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{‘ token
before evrey function.
code:
- #include <avrio.h>
- #include <stdio.h>
- #include <avrdelay.h>
- #include <math.h>
- void initialize(void);
- char val;
- // current measurement state
- enum {PULSE, GSR, BREATH} measure, nextmeasure;
- // current signal voltages
- char pulseV = 0;
- char gsrV = 0;
- char breathV = 0;
- // enter every 100Hz
- interrupt(TIM0_COM) void getAD(void)
- {
- // sample A/D and store
- val = ADCH;
- // start a/d converter
- switch(measure)
- {
- case PULSE:
- pulseV = val << 1;
- nextmeasure = GSR;
- break;
- case GSR:
- gsrV = val;
- nextmeasure = BREATH;
- break;
- case BREATH:
- breathV = val;
- nextmeasure = PULSE;
- break;
- }
- switch(nextmeasure)
- {
- case PULSE: ADMUX = 0b01100001; break;
- case GSR: ADMUX = 0b01100010; break;
- case BREATH: ADMUX = 0b01100011; break;
- }
- measure = nextmeasure;
- ADCSR.6 = 1;
- }
- // send signals to MATLAB for drawing
- void transmit()
- {
- printf(«%d «, (int)pulseV);
- printf(«%d «, (int)gsrV);
- printf(«%d «, (int)breathV);
- printf(«r»); // end packet
- PORTD.7 = ~PORTD.7;
- }
- // read A/D converter and communicate with MATLAB
- void main(void)
- {
- char inchar;
- initialize();
- while(1)
- {
- // when signaled by MATLAB, return current values
- if (UCSRA.7)
- {
- inchar = UDR;
- if (inchar==’s’) {
- transmit();
- }
- }
- }
- }
- // setup
- void initialize(void)
- {
- // comm indicator LED
- DDRD.7 = 1;
- PORTD.7 = 0;
- // serial RS-232 setup for debugging using printf, etc.
- UCSRB = 0x18;
- UBRRL = 103;
- // set up timer0 to sample a/d at about 100Hz
- TCCR0 = 0b00000101;
- TIMSK = 0b00000010;
- OCR0 = 156;
- // set up a/d for external Vref, channel 0
- // channel zero / left adj / AVcc Reference
- // A1=PULSE, A2=GSR, A3=BREATH
- ADMUX = 0b01100001;
- // enable ADC and set prescaler to 1/128*16MHz=125kHz
- // and clear interupt enable
- // and start a conversion
- ADCSR = 0b11000111;
- measure = PULSE;
- _sei();
- }
Oct 18 ’09
#1