Error expected primary expression at end of input

  • Forum
  • General C++ Programming
  • Error expected at the end of input../pri

Error expected at the end of input../primary expression

Hi, I am writing a program and ive recive these two errors all of a sudden saying Error expected at the end of input and error expected primary expression at at the end of input… Can anyone figure out the error?
Line error is on the last line

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#include<iostream>
#include<cstdlib>
#include<conio.h>
#include<cmath>
   using namespace std;
int main ()
    {
int loopcount=0;
int total=0;
  int Total1=1;
char choice, choice1, choice2, choice3, choice4;
   int Answer,x,y;
   int NumbersAmount;
   int number;
 double x1,y1;
 double Answer1;
   double angle;
   system("COLOR 0c");
     cout<<"             Welcome to TwoSixEight Geeka Scientific Calculatorn";
   cout << "                      Coded by Jenell Joanne Jamesnn";

  cout << " n Enter the number of the function you'd like to calculaten";
   do {
     cout<<"t1 ~ Arithmetic Operations n: ";
     cout<<"t2 ~ Trigonometric Functions n: ";
     cout<<"t3 ~ Logarithmic Functions n: ";
     cout<<"t4 ~ Power Functions n: ";
     cout<<"t5 ~ Exitnn:";


     choice = getche();



     switch(choice)

     {
   case '1':

      {
   cout<< " nn Welcome to the Arithmetic Operationsnn";
   cout<<" Enter the number of the operator you will like to selectn";
              cout<<"t1 : Addition n: ";
              cout<<"t2 : subtraction n: ";
              cout<<"t3 : Multiplication n: ";
              cout<<"t4 : Division n: ";
              choice1 = getche();
               switch(choice1)
                  {
                    case '1':
                             {
                            cout << "How many numbers are  you adding?n";
                            cin >> NumbersAmount;

                             while (loopcount < NumbersAmount){
                               cout<<"Enter a number: ";
                               cin>>number;
                              total = total + number;
                                 loopcount = loopcount+1;

                            }
                             cout<<" Total is "<<total<<endl;


                              break;

                              }
                    case '2':
                          {
                       cout<<"Enter first number: ";
                      cin>>x;
                       cout<<"Enter an other number: ";
                       cin>>y;
                             Answer=x-y;
                       cout<<"The Answer is "<<Answer<<endl;

                        break;
                           }

                    case '3':
                             {
                               cout << "nHow many numbers are you entering?n";
                            cin >> NumbersAmount;

                             while (loopcount < NumbersAmount){
                               cout<<"Enter your numbern";
                               cin>>number;
                                Total1 = Total1 * number;
                                 loopcount = loopcount+1;

                             }
                              cout<<" Total is"<<Total1<<endl;

                              break;

                       }

                   case '4':
                             {
                         cout<<"Enter first number: ";
                          cin>>x;
                          cout<<"Enter an other number: ";
                           cin>>y;
                         if(x!=0)
                          {
                           Answer=x/y;
                             cout<<"The Answer is "<<Answer<<endl;


                          }
                                break;
                             }

                 }// end of inner switch
                 break;
           }// end of case 1 arithmetic operation

  case '2':
            {
       cout<<" Welcome to Trigonometric Functionsnn";
             cout<<"1 ~ Sin functionn:";
             cout<<"2 ~ Cos functionn:";
             cout<<"3 ~ Tan functionnn:";
             cout<<" Choose your function by typing in the associated number";
       choice2=getche();
       switch(choice2)
       {
       case '1':        {
        cout<<"Enter a angle: ";
        cin>>angle;

       Answer1=(sin(angle));
        cout<<"The answer is  "<<Answer1<<endl;

        break;
        }
       case '2':
        {
       cout<<" Enter a number: ";
       cin>>angle;
       Answer1=(cos(angle));
       cout<<"The answer is "<<Answer1<<endl;

         break;
        }
       case '3':
       {
       cout<< "Enter a number: ";
        cin>>angle;
          Answer1=(tan(angle));
         cout<<"The answer is "<<Answer1<<endl;

         break;
        }

      }// inner switch
       break;
            }//inner case 2 trignomatic
       case '3':
            {

       cout<<"n1 ~ Natural log:";
       cout<<"n2 ~Log with base 10:n";
       choice3=getche();
       switch(choice3)
       {
      case '1':
        {
       cout<<" Enter a number: ";
        cin>>x1;
        Answer1=log(x1);
       cout<<"The answer is  "<<Answer1<<endl;

       break;
      }
      case '2':
        {
        cout<<"Enter a number: ";
        cin>>x1;
               Answer1= log10(x1);
        cout<<"The answer is "<<Answer1<<endl;

        break;
        }
              }// end of switch
          break;
            }// end of case 3 logrithmic
       case '4':
            {

       cout<<"t ~  Press 1 for Powern";
       cout<<"t ~  Press 2 for Square root:n";
       cout<<"t ~  Press 3 for Squaren";
      cout<<"t ~  Press 4 for Cubenn";
       cout<<"tEnter your choicenn:";
       choice4=getche();
      switch(choice4)
       {
       case '1':
        {
        cout<<"      Enter a number: ";
         cin>>x1;
         cout<<"      Enter power: ";
         cin>>y1;         Answer1=pow(x1,y1);
         cout<<"The Answer is  "<<Answer1<<endl;

         break;
        }
       case '2':
        {
         cout<<"      Enter a number: ";
         cin>>x;
         Answer1=sqrt(x);
         cout<<"The Answer is "<<Answer1<<endl;

         break;

        }
        case '3':
          {
       cout<<"        Enter a number: ";
             cin>>x;
              Answer1= x*x;
              cout<<" The Answer is"<<Answer1<<endl;

  break;

  }
  case '4':
  {
  cout<<"             Enter a number: ";
  cin>>x;
  Answer1 =x*x*x;
 cout<<" The answer is"<<Answer1<<endl;
  break;
  }
       }//end switch
      break;
  }//end of case power function    }//outer switch
    }
    while (choice!='5');
  }
return 0 ;
} 

Last edited on

Didn’t you get a line number with the error message? Or does your system expect you to be a mindreader?

The error line is 243

..

Last edited on

my apologies the brace is in my program , i just missed it out here.. will enter it in now… but my errors still remains on the last line

I just had a quick look at your code using the shell and also what you presneted here.

You have a series of stuff ups with braces etc and you will need to:
1. Properly present your code professionally especially using proper indentation.
2. Line 241 is rubbish that does nothing. Get rid of it.
3. Make sure all braces balance.

You’re in for some fairly easy editing and debugging if you do that and if you understand the code you’re using.

Last edited on

Multiple poster pest — music just stopped from me.

http://www.cplusplus.com/forum/general/180016/

Last edited on

Topic archived. No new replies allowed.

Лизаветка

1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

1

01.05.2017, 21:41. Показов 35821. Ответов 13

Метки нет (Все метки)


Посмотрите, пожалуйста. Выдает ошибку expected ‘}’ at end of input, но скобки везде попарно

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
int main()
{
    setlocale(LC_ALL, "Russian");
    inform();
    getch();
    system("cls");//новая страница
    char zapros_menu, vspom_zapr;
    glavnoe_menu();
    vspom_zapr=zapr_menu();
    int otvet;
    while (vspom_zapr!='0')
    {
        zapros_menu=vspom_zapr;
        system("cls");
        switch (zapros_menu)
        {
        case '1':
            {
                svedenia_po_program();
            }
        case '2':
            {
                otvet=TEORIA::demonstrate();
            }
        case '3':
            {
 
            }
        case '4':
            {
 
            }
        case '5':
            {
 
            }
        };
        getch();
        system("cls");
        glavnoe_menu();
        if (otvet==0)
        {
            vspom_zapr=0;
        } else
        {
            vspom_zapr=zapr_menu();
        };
    };
    return 0;
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 21:53

2

а на какой строке вылетает ошибка?



0



284 / 232 / 114

Регистрация: 07.09.2016

Сообщений: 584

01.05.2017, 21:57

3

привыкайте нормально код форматировать. черт ногу сломит в такой писанине.
по ошибке: если это студия и в начале файла нет #include «stdafx.h» — то в этом может быть причина.
может есть другой код, который вы не написали тут, но он есть. например тут нед вообще ни
одного инклуда, что там у вас еще есть, чего вы не запостили известно только вам.



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 21:59

4

Во-первых, если операция только одна, то операторные скобки необязательны (хотя бы не запутаетесь)
Во-вторых, так как Вы не привели полный код программы, откуда нам знать, что эта ошибка не возникает во всяких подпрограммах типа zapr_menu()?



0



Лизаветка

1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

01.05.2017, 22:07

 [ТС]

5

вот полный код программы, выдает ошибку в последней строке, пробовала убирать частично код программы, ошибка уходит, если только убрать строки #include «teoria.h» и #include «teoria.cpp, выходит ошибка в них

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <iostream>
#include <fstream>
#include <conio.h>
#include <stdlib.h>
#include <string>
 
#include "teoria.h"
 
#include "teoria.cpp"
 
using namespace std;
 
void inform()
{
    cout << "n"
    "        Астраханский государственный технический университетn"
    "          Институт Информационных технологий и коммуникацийnnn"
    "                                                Кафедраn"
    "                                                Автоматизированных системn"
    "                                                бработки информации и управленияnnnnn"
    "                     Курсовая работа по дисциплинеn"
    "                   'Программирование и информатика'n"
    "        Учебно - демонстрационная программа <<Сортировка Бэтчера>>nnnn"//свет
    "                                                Выполнила: студентка группы ДИНРб-11n"
    "                                                Бондаренко Е. М.n"//свет
    "                                                Руководитель работыn"
    "                                                Ст. преп. Толасова В. В.nnnnn"
    "                          г.АСТРАХАНЬ  2017г.nn ";
};
 
void glavnoe_menu()
{
    cout << "nn     Учебно-демонстрационная программа <<Cортировка Бэтчера>> n";//свет
    cout << "nnn*************************";
    cout << "<Главное Меню>";//свет
    cout <<    "****************************nn" <<endl;
    cout << "                                                   клавишаnn";
    cout << "            Сведения о работе программы..............";
    cout << " 1nn";//свет
    cout << "            Теоретический материал...................";
    cout << " 2nn";//свет
    cout << "            Пошаговая демонстрация сортировки........";
    cout << " 3nn";//свет
    cout << "            Тест по пройденному материалу............";
    cout << " 4nn";//свет
    cout << "            Зайти как администратор..................";
    cout << " 5nn";//свет
    cout << "            Выход....................................";
    cout << " 0nn";//свет
};
 
char zapr_menu()
{
    char zapr;
    cin >> zapr;
    while (zapr!='0' && zapr!='1' && zapr!='2' && zapr!='3' && zapr!='4' && zapr!='5')
    {
        cout << "nНекорректный ввод! Повторите!n";
        cin >> zapr;
    };
    return zapr;
};
 
void svedenia_po_program()
{
    ifstream out("svedenia.txt");
    if(out.is_open())
    {
        while (!out.eof())
        {
            string stroka;
            getline(out, stroka, 'n');
            cout << "n   " << stroka;
        }
    };
    out.close();
};
 
int main()
{
        setlocale(LC_ALL, "Russian");
    inform();
    getch();
    system("cls");//новая страница
    char zapros_menu, vspom_zapr;
    glavnoe_menu();
        vspom_zapr=zapr_menu();
         int otvet;
    while (vspom_zapr!='0')
        {
             zapros_menu=vspom_zapr;
             system("cls");
             switch (zapros_menu)
            {
            case '1':
                {
                       svedenia_po_program();
                }
            case '2':
               {
                      otvet=TEORIA::demonstrate();
                }
            case '3':
               {
 
                }
            case '4':
               {
 
                }
             case '5':
               {
 
                }
        };
        getch();
        system("cls");
        glavnoe_menu();
        if (otvet==0)
        {
            vspom_zapr=0;
        } else vspom_zapr=zapr_menu();
    };
    return 0;
}



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 22:11

6

Цитата
Сообщение от Лизаветка
Посмотреть сообщение

#include «teoria.cpp»

что значит #include исходный код C++? Вы подключаете и хедер teoria.h и исходник teoria.cpp



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 22:12

7

И учитесь уже обрамлять код тегами [CPP]

Миниатюры

ошибка expected '}' at end of input
 



0



1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

01.05.2017, 22:15

 [ТС]

8

спасибо, впредь буду оформлять нормально, это мои первые 15 минут на данном форуме)



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 22:16

9

Лизаветка, ну а насчет инклюдов Вы поняли?



0



Лизаветка

1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

01.05.2017, 22:20

 [ТС]

10

нет. я подключаю и то и то, без хедера ошибка остается.
вот что у меня представляет teoria.cpp

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "teoria.h"
 
#include <iostream>
#include <fstream>
#include <ctime>
#include <conio.h>
#include <windows.h>
 
using namespace std;
 
namespace TEORIA
{
 
    void mini_menu()
    {
        cout << "nn                                          клавишаnn";
        cout << "            Назад...........................";
        cout << " 1n";//свет
        cout << "            Вперед..........................";
        cout << " 2n";//свет
        cout << "            Главное меню....................";
        cout << " 3n";//свет
        cout << "            Выход...........................";
        cout << " 0n";//свет
    }
 
    char numb_menu()
    {
        char zap;
        cin >> zap;
        while(zap!='1' && zap!='2' && zap!='3' && zap!='0')
        {
            cout << "nНекорректный ввод! Повторите!n";
            cin >> zap;
        };
        return zap;
    }
 
    void display_str(char* name)
    {
        ifstream str(name);
        if(str.is_open())
        {
            while (!str.eof())
            {
                string stroka;
                getline(str, stroka, 'n');
                cout << "n   " << stroka;
            }
        };
        str.close();
    }
 
    int demonstrate()
    {
        char dop_zapr='1';
        char zapros_menu='1';
        int otvet;
        do
        {
            switch (dop_zapr)
            {
            case '1':
                {
                    char name[20]="teor_1.txt";
                    display_str(name);
                }
            case '2':
                {
                    char name[20]="teor_2.txt";
                    display_str(name);
                }
            case '3':
                {
                    char name[20]="teor_3.txt";
                    display_str(name);
                }
            case '4':
                {
                    char name[20]="teor_4.txt";
                    display_str(name);
                }
            }
            mini_menu();
            zapros_menu=numb_menu();
            if (zapros_menu=='1')
            {
                dop_zapr++;
            } else dop_zapr--;
        } while (zapros_menu!='3' && zapros_menu!='0' && dop_zapr!='5' && dop_zapr!='0');
        if (zapros_menu=='0') otvet=0; else otvet=1;
        return otvet;
}

и вот teoria.h

C++
1
2
3
4
5
6
7
8
9
10
11
#ifndef TEORIA_H_INCLUDED
#define TEORIA_H_INCLUDED
 
namespace TEORIA
{
    void mini_menu();
    char numb_menu();
    void display_str(char name);
    int demonstrate();
}
#endif // TEORIA_H_INCLUDED

Что нужно убрать?



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 22:22

11

Лизаветка, вопрос остается прежним: на какой строке и в каком файле возникает ошибка? Можно скриншот скинуть, если сами не разбираетесь



0



DU3

284 / 232 / 114

Регистрация: 07.09.2016

Сообщений: 584

01.05.2017, 22:24

12

Лучший ответ Сообщение было отмечено Лизаветка как решение

Решение

нормально форматируйте не только тут на форуме, но и у себя в редакторе и такого рода проблем будет на порядок меньше.
подозреваю что в teoria.cpp нет закрывающей скобки от

C++
1
2
namespace TEORIA
{



1



Joey

01.05.2017, 22:29

Не по теме:

DU3, ждем ебилдов ТС



0



1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

01.05.2017, 22:35

 [ТС]

14

Спасибо за ответы) ошибка выволилась на последней строке основной программы, оказалось нет закрывабщейся скобки в файле teoria.cpp , спасибо за вопросы, буду работать над оформлением��



1



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

01.05.2017, 22:35

Помогаю со студенческими работами здесь

Ошибка: Expected END but received ELSE
Всем привет , кто может помочь?!) строка 59 ругается на else. (expected END but received ELSE).

Ошибка: ‘END’ expected but ‘ELSE’ found
Задание:
Написать программу, которая бы по введенному номеру времени года (1 — зима, 2 — весна, 3…

Ошибка: ‘END’ expected but ‘UNTIL’ found
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,…

Ошибка ‘Expected END but recieved’
Понимаю,что ошибка связанная с begin и end,но я не догоняю,где пропущеноunit Unit2;

interface

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

14

I get the following error when I compile:

convert.cpp: In function 'std::string convert()':
convert.cpp:62: error: expected primary-expression before 'else'
convert.cpp:62: error: expected `;' before 'else'
convert.cpp:108: error: expected `}' at end of input
convert.cpp:108: error: expected `}' at end of input 
convert.cpp:108: error: expected `}' at end of input 
convert.cpp:108: error: expected `}' at end of input 
convert.cpp:108: error: expected `}' at end of input

Code:

#include<iostream>
#include<stack>
#include<string>
using namespace std;

string infix;  // infix expression string
string operand;
string operate;
stack <string> mystack; // this stack is used to push the operator
string postfix;  // postfix string where the operand is appended

//....................................................................
// this function read the infix expression from user 
string input()
{
 cout<<" Enter the damn infix expression: "<<endl; 
 getline(cin, infix);
 return infix;
}
//......................................................................
// this function checks for operator precedence in the stack
int precedence(string e)
{
int f;
if(e == "*" || e== "/" || e =="%")
 f = 2;
else
{
if(e == "+" || e == "-")
 f = 1;
}

if(e=="."){
f=0;
}

return f;

}




//....................................................................
// This function converts infix to postfix
string convert()
{ 
 for(int i=0; i<infix.length(); i++)
 { 

  switch(infix[i]){

  // operate case start  
  case '+': case'-': case'*': case'/': case'^': case '(': case ')': case'.':

  operate=infix[i];
  {
  if(mystack.empty() || precedence(operate)>= precedence(mystack.top()))
  {
    mystack.push(operate);           

   else
   {
    while(precedence(operate)<= precedence(mystack.top()))
    {
     postfix.append(mystack.top());
     mystack.pop();
    }

    mystack.push(operate); 
   }

  }
  }//operate case closed

  default:        //when operand string char is parsed
  {
                        operand=infix[i];
                        postfix.append(operand);
                        break;

  } // default case closed

  }//switch closed

 }

while(!mystack.empty())
{
 postfix.append(mystack.top())
 mystack.pop();
}

return postfix;
cout<<postfix;
}



//...................................................................
int main()
{

input();

convert();
cout<<"postfix is "<<postfix<<endl;
} 

SCFrench's user avatar

SCFrench

8,2162 gold badges31 silver badges61 bronze badges

asked Oct 3, 2010 at 0:14

udaysubedi's user avatar

It appears that your code is just missing some closing braces. That’s all.

For example, look at this:

  operate=infix[i];
  {
  if(mystack.empty() || precedence(operate)>= precedence(mystack.top()))
  {
    mystack.push(operate);           

   else
   {
    while(precedence(operate)<= precedence(mystack.top()))

Where is the closing } before the else statement. Just go through your code and fix these silly mistakes.

It would be a lot easier to rid yourself of these things if you made your spacing and indentation a little neater.

answered Oct 3, 2010 at 0:23

Alexander Rafferty's user avatar

1

The «expected primary expression before else» diagnostic is the compiler-author’s way of reporting you rudely foisted on him an «else» without either a preceding «if» or (what amounts to the same thing) «else if». Alexander Rafferty correctly points out that this is because the code has …

if (condition) {
  // ...
  else { }

… when perhaps what you meant was …

if (condition) {
   // ...
}
else {
}

… though maybe you deleted a whole bunch of stuff by accident, and were lucky enough that the deletion resulted in unparseable code, so you will realize that something is wrong.

answered Oct 3, 2010 at 0:48

Thomas L Holaday's user avatar

Thomas L HoladayThomas L Holaday

13.5k6 gold badges40 silver badges51 bronze badges

Look at these lines:

if(mystack.empty() || precedence(operate)>= precedence(mystack.top()))
{
   mystack.push(operate);           

else

answered Oct 3, 2010 at 1:13

Martin York's user avatar

Martin YorkMartin York

253k84 gold badges332 silver badges555 bronze badges

0

Here’s the whole error:

 Arduino: 1.6.7 (Windows 7), Board: "Arduino/Genuino Uno"

 *readMifarereadMifare.ino: In function 'void loop()':

 readMifare:113: error: expected primary-expression before ']' token

    if (uid[] == { 0x04, 0xEC, 0x89, 0x32, 0x55, 0x42, 0x80 }) {

            ^

 readMifare:113: error: expected primary-expression before '{' token

    if (uid[] == { 0x04, 0xEC, 0x89, 0x32, 0x55, 0x42, 0x80 }) {

                 ^

 readMifare:113: error: expected ')' before '{' token

 readMifare:121: error: expected '}' at end of input

    }

    ^

 exit status 1
 expected primary-expression before ']' token

   This report would have more information with
   "Show verbose output during compilation"
   enabled in File > Preferences.

Here’s the code

 #include <Wire.h>
 #include <SPI.h>
 #include <Adafruit_PN532.h>

 // If using the breakout with SPI, define the pins for SPI communication.
 #define PN532_SCK  (2)
 #define PN532_MOSI (3)
 #define PN532_SS   (4)
 #define PN532_MISO (5)
 // If using the breakout or shield with I2C, define just the pins connected
 // to the IRQ and reset lines.  Use the values below (2, 3) for the shield!
 #define PN532_IRQ   (2)
 #define PN532_RESET (3)  // Not connected by default on the NFC Shield

 // Uncomment just _one_ line below depending on how your breakout or shield
 // is connected to the Arduino:

 // Use this line for a breakout with a software SPI connection (recommended):
 Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);

 // Use this line for a breakout with a hardware SPI connection.  Note that
 // the PN532 SCK, MOSI, and MISO pins need to be connected to the Arduino's
 // hardware SPI SCK, MOSI, and MISO pins.  On an Arduino Uno these are
 // SCK = 13, MOSI = 11, MISO = 12.  The SS line can be any digital IO pin.
 //Adafruit_PN532 nfc(PN532_SS);

 // Or use this line for a breakout or shield with an I2C connection:
 //Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

 #if defined(ARDUINO_ARCH_SAMD)
 // for Zero, output on USB Serial console, remove line below if using      programming port to program the Zero!
 // also change #define in Adafruit_PN532.cpp library file
 #define Serial SerialUSB
 #endif
 #include <Servo.h>

 Servo servo1;

 void setup(void) {
   #ifndef ESP8266
   while (!Serial); // for Leonardo/Micro/Zero
   #endif
   Serial.begin(115200);
   Serial.println("Hello!");

   nfc.begin();

   uint32_t versiondata = nfc.getFirmwareVersion();
   if (! versiondata) {
     Serial.print("Didn't find PN53x board");
     while (1); // halt
   }
   // Got ok data, print it out!
   Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
   Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
   Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);

   // configure board to read RFID tags
   nfc.SAMConfig();

   Serial.println("Waiting for an ISO14443A Card ...");
   servo1.attach(9); 
 }


 void loop(void) {
   uint8_t success;
   uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
   uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

   // Wait for an ISO14443A type cards (Mifare, etc.).  When one is found
   // 'uid' will be populated with the UID, and uidLength will indicate
   // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
   success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

   if (uid[] = { 0x04, 0xEC, 0x89, 0x32, 0x55, 0x42, 0x80 }) {

      int position;
      for(position = 0; position < 180; position += 2){
       servo1.write(position);
       delay(20);
      }

   }

Please note that I’m using an example from the Adafruit official PN532 library examples and trying to edit it.

I’m having the same problem even with GCC 4.8

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 
Command gcc -v exited successfully with status 0.
Took 0.00512 seconds.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/go/.bundled-gems/gems/sassc-1.10.1/ext
/opt/local/rbenv/versions/2.3.0/bin/ruby -rubygems
/var/go/.bundled-gems/gems/rake-11.3.0/exe/rake
RUBYARCHDIR=/var/go/.bundled-gems/extensions/x86_64-linux/2.3.0-static/sassc-1.10.1
RUBYLIBDIR=/var/go/.bundled-gems/extensions/x86_64-linux/2.3.0-static/sassc-1.10.1
cd libsass
make lib/libsass.so
mkdir lib
cc -Wall -O2 -I /var/go/.bundled-gems/gems/sassc-1.10.1/ext/libsass/include
-fPIC -fPIC -c -o src/cencode.o src/cencode.c
g++ -Wall -O2 -std=c++0x -I
/var/go/.bundled-gems/gems/sassc-1.10.1/ext/libsass/include -fPIC -fPIC -c -o
src/ast.o src/ast.cpp
In file included from src/ast.cpp:2:
src/ast.hpp: In member function ‘virtual size_t Sass::Vectorized<T>::hash()’:
src/ast.hpp:257: error: expected initializer before ‘:’ token
src/ast.hpp:260: error: expected primary-expression before ‘}’ token
src/ast.hpp:260: error: expected ‘;’ before ‘}’ token
src/ast.hpp:260: error: expected primary-expression before ‘}’ token
src/ast.hpp:260: error: expected ‘)’ before ‘}’ token
src/ast.hpp:260: error: expected primary-expression before ‘}’ token
src/ast.hpp:260: error: expected ‘;’ before ‘}’ token
src/ast.hpp: In constructor ‘Sass::Hashed::Hashed(size_t)’:
src/ast.hpp:307: error: ‘class std::unordered_map<Sass::Expression*,
Sass::Expression*, Sass::Hashed::HashExpression,
Sass::Hashed::CompareExpression, std::allocator<std::pair<Sass::Expression*
const, Sass::Expression*> > >’ has no member named ‘reserve’
src/ast.hpp: In member function ‘Sass::Hashed&
Sass::Hashed::operator+=(Sass::Hashed*)’:
src/ast.hpp:336: error: expected initializer before ‘:’ token
src/ast.hpp:340: error: could not convert ‘Sass::Hashed::reset_duplicate_key()’
to ‘bool’
src/ast.hpp:341: error: expected primary-expression before ‘return’
src/ast.hpp:341: error: expected ‘)’ before ‘return’
src/ast.hpp: In member function ‘virtual size_t Sass::Map::hash()’:
src/ast.hpp:936: error: expected initializer before ‘:’ token
src/ast.hpp:940: error: expected primary-expression before ‘}’ token
src/ast.hpp:940: error: expected ‘;’ before ‘}’ token
src/ast.hpp:940: error: expected primary-expression before ‘}’ token
src/ast.hpp:940: error: expected ‘)’ before ‘}’ token
src/ast.hpp:940: error: expected primary-expression before ‘}’ token
src/ast.hpp:940: error: expected ‘;’ before ‘}’ token
src/ast.hpp: In member function ‘virtual size_t Sass::Function_Call::hash()’:
src/ast.hpp:1232: error: expected initializer before ‘:’ token
src/ast.hpp:1234: error: expected primary-expression before ‘}’ token
src/ast.hpp:1234: error: expected ‘;’ before ‘}’ token
src/ast.hpp:1234: error: expected primary-expression before ‘}’ token
src/ast.hpp:1234: error: expected ‘)’ before ‘}’ token
src/ast.hpp:1234: error: expected primary-expression before ‘}’ token
src/ast.hpp:1234: error: expected ‘;’ before ‘}’ token
src/ast.hpp: In member function ‘virtual size_t Sass::Number::hash()’:
src/ast.hpp:1361: error: expected initializer before ‘:’ token
src/ast.hpp:1363: error: expected primary-expression before ‘for’
src/ast.hpp:1363: error: expected ‘;’ before ‘for’
src/ast.hpp:1363: error: expected primary-expression before ‘for’
src/ast.hpp:1363: error: expected ‘)’ before ‘for’
src/ast.hpp:1363: error: expected initializer before ‘:’ token
src/ast.hpp:1365: error: expected primary-expression before ‘}’ token
src/ast.hpp:1365: error: expected ‘;’ before ‘}’ token
src/ast.hpp:1365: error: expected primary-expression before ‘}’ token
src/ast.hpp:1365: error: expected ‘)’ before ‘}’ token
src/ast.hpp:1365: error: expected primary-expression before ‘}’ token
src/ast.hpp:1365: error: expected ‘;’ before ‘}’ token
src/ast.hpp: In member function ‘bool Sass::String_Schema::has_interpolants()’:
src/ast.hpp:1502: error: expected initializer before ‘:’ token
src/ast.hpp:1505: error: expected primary-expression before ‘return’
src/ast.hpp:1505: error: expected ‘;’ before ‘return’
src/ast.hpp:1505: error: expected primary-expression before ‘return’
src/ast.hpp:1505: error: expected ‘)’ before ‘return’
src/ast.hpp: In member function ‘virtual size_t Sass::String_Schema::hash()’:
src/ast.hpp:1514: error: expected initializer before ‘:’ token
src/ast.hpp:1516: error: expected primary-expression before ‘}’ token
src/ast.hpp:1516: error: expected ‘;’ before ‘}’ token
src/ast.hpp:1516: error: expected primary-expression before ‘}’ token
src/ast.hpp:1516: error: expected ‘)’ before ‘}’ token
src/ast.hpp:1516: error: expected primary-expression before ‘}’ token
src/ast.hpp:1516: error: expected ‘;’ before ‘}’ token
In file included from src/ast.cpp:2:
src/ast.hpp: In member function ‘virtual size_t
Sass::Compound_Selector::hash()’:
src/ast.hpp:2261: error: ‘template<class T> class Sass::Vectorized’ used without
template parameters
src/ast.hpp: In member function ‘virtual size_t Sass::Selector_List::hash()’:
src/ast.hpp:2488: error: ‘template<class T> class Sass::Vectorized’ used without
template parameters
src/ast.hpp: In member function ‘virtual void
Sass::Selector_List::set_media_block(Sass::Media_Block*)’:
src/ast.hpp:2505: error: expected initializer before ‘:’ token
src/ast.hpp:2508: error: expected primary-expression before ‘}’ token
src/ast.hpp:2508: error: expected ‘;’ before ‘}’ token
src/ast.hpp:2508: error: expected primary-expression before ‘}’ token
src/ast.hpp:2508: error: expected ‘)’ before ‘}’ token
src/ast.hpp:2508: error: expected primary-expression before ‘}’ token
src/ast.hpp:2508: error: expected ‘;’ before ‘}’ token
src/ast.cpp: In function ‘std::string& Sass::str_ltrim(std::string&)’:
src/ast.cpp:33: error: expected primary-expression before ‘[’ token
src/ast.cpp:33: error: expected primary-expression before ‘]’ token
src/ast.cpp:33: error: expected primary-expression before ‘char’
src/ast.cpp:33: error: unable to deduce ‘auto’ from ‘<expression error>’
src/ast.cpp: In function ‘std::string& Sass::str_rtrim(std::string&)’:
src/ast.cpp:40: error: expected primary-expression before ‘[’ token
src/ast.cpp:40: error: expected primary-expression before ‘]’ token
src/ast.cpp:40: error: expected primary-expression before ‘char’
src/ast.cpp:40: error: unable to deduce ‘auto’ from ‘<expression error>’
src/ast.cpp: In member function ‘virtual bool
Sass::Compound_Selector::has_parent_ref()’:
src/ast.cpp:139: error: expected initializer before ‘:’ token
src/ast.cpp:142: error: expected primary-expression before ‘return’
src/ast.cpp:142: error: expected ‘;’ before ‘return’
src/ast.cpp:142: error: expected primary-expression before ‘return’
src/ast.cpp:142: error: expected ‘)’ before ‘return’
src/ast.cpp: In member function ‘virtual bool
Sass::Compound_Selector::is_superselector_of(Sass::Selector_List*,
std::string)’:
src/ast.cpp:661: error: expected initializer before ‘:’ token
src/ast.cpp:664: error: expected primary-expression before ‘return’
src/ast.cpp:664: error: expected ‘;’ before ‘return’
src/ast.cpp:664: error: expected primary-expression before ‘return’
src/ast.cpp:664: error: expected ‘)’ before ‘return’
src/ast.cpp: In member function ‘Sass::Selector_List*
Sass::Complex_Selector::parentize(Sass::Selector_List*, Sass::Context&)’:
src/ast.cpp:1171: error: expected initializer before ‘:’ token
src/ast.cpp:2216: error: expected primary-expression at end of input
src/ast.cpp:2216: error: expected ‘;’ at end of input
src/ast.cpp:2216: error: expected primary-expression at end of input
src/ast.cpp:2216: error: expected ‘)’ at end of input
src/ast.cpp:2216: error: expected statement at end of input
src/ast.cpp:2216: error: expected ‘}’ at end of input
src/ast.cpp:2216: error: expected ‘}’ at end of input
src/ast.cpp: At global scope:
src/ast.cpp:2216: error: expected ‘}’ at end of input
src/units.hpp:10: warning: ‘Sass::PI’ defined but not used
make: *** [src/ast.o] Error 1
rake aborted!
Command failed with status (2): [make lib/libsass.so...]
/var/go/.bundled-gems/gems/sassc-1.10.1/lib/tasks/libsass.rb:29:in `block (2
levels) in <top (required)>'
/var/go/.bundled-gems/gems/sassc-1.10.1/lib/tasks/libsass.rb:11:in `block (3
levels) in <top (required)>'
/var/go/.bundled-gems/gems/sassc-1.10.1/lib/tasks/libsass.rb:10:in `block (2
levels) in <top (required)>'
/var/go/.bundled-gems/gems/rake-11.3.0/exe/rake:27:in `<main>'
Tasks: TOP => lib/libsass.so
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /var/go/.bundled-gems/gems/sassc-1.10.1 for
inspection.
Results logged to
/var/go/.bundled-gems/extensions/x86_64-linux/2.3.0-static/sassc-1.10.1/gem_make.out

An error occurred while installing sassc (1.10.1), and Bundler cannot continue.
COMMENT(support( void(void) ))
^

zc_functionobjects.cpp(32): warning #12: parsing restarts here after previous syntax error
}lambda3;
^

zc_functionobjects.cpp(34): error #77: this declaration has no storage class ortype specifier
lambda3(lam);
^

zc_functionobjects.cpp(34): error: identifier «lam» is undefined
lambda3(lam);
^

zc_functionobjects.cpp(41): error: identifier «LAMBDA» is undefined
LAMBDA val;
^

zc_functionobjects.cpp(43): error: identifier «LAMBDA» is undefined
Lambda1(LAMBDA l) : val(l)
^

zc_functionobjects.cpp(54): error #303: explicit type is missing («int» assumed)

lambda4();
^

zc_functionobjects.cpp(54): error: declaration is incompatible with «Lambda1 lambda4» (declared at line 52)
lambda4();
^

zc_functionobjects.cpp(57): error: identifier «Dummy» is undefined
void (*p)(void) = &Dummy;
^

zc_functionobjects.cpp(96): error: function returning function is not allowed
lambda5()();
^

zc_functionobjects.cpp(96): error: declaration is incompatible with «Lambda2 lambda5» (declared at line 94)
lambda5()();
^

zc_functionobjects.cpp(104): error: identifier «LAMBDA» is undefined
LAMBDA lambda;
^

zc_functionobjects.cpp(110): error: identifier «LAMBDA» is undefined
LAMBDA lambda;
^

zc_functionobjects.cpp(114): error: identifier «LAMBDA» is undefined
InnerLambda(LAMBDA l) : lambda(l)
^

zc_functionobjects.cpp(127): error: identifier «LAMBDA» is undefined
Lambda3(LAMBDA l) : lambda(l), innerLambda(lambda)
^

zc_functionobjects.cpp(148): error: identifier «LAMBDA» is undefined
LAMBDA lambda;
^

zc_functionobjects.cpp(152): error: identifier «LAMBDA» is undefined
InnerLambda(LAMBDA l) : lambda(l)
^

zc_functionobjects.cpp(165): error: identifier «LAMBDA» is undefined
InnerLambda operator () (LAMBDA l)
^

zc_functionobjects.cpp(171): error #77: this declaration has no storage class or type specifier
lambda7(lam);
^

zc_functionobjects.cpp(171): error: variable «lambda7» has already been defined
lambda7(lam);
^

zc_functionobjects.cpp(174): error #77: this declaration has no storage class or type specifier
result(lam);
^

zc_functionobjects.cpp(175): error: expected a declaration
}
^

zc_functionobjects.cpp(195): warning #12: parsing restarts here after previous syntax error

compilation aborted for zc_functionobjects.cpp (code 2)

  1. Я новичок написал вот такой скетч ( со строки {int Hours_62193421_1; компиляция c flprog)

    #include <TM1637.h>

    const int butSPin = 2;

    int butSState = 0;

    void setup() {
    pinMode (butSPin , INPUT);

    }

    int flag=0;

    void loop(){
    if(digitalRead(butSState)==HIGH&&flag==0)

    {int Hours_62193421_1;
    int Mins_62193421_1;
    bool Sec_62193421_1;
    int Brightness_62193421_1;
    TM1637 tm1637_62193421_1(7 , 8);
    int8_t TimeDisp_62193421_1[] = {0x00,0x00,0x00,0x00};
    int _gtv1;
    int _gtv2;
    bool _gtv4;
    int _gtv5;
    bool _gtv6;
    bool _gtv7;
    bool _gtv8;
    bool _gtv9;
    bool _trgrt6 = 0;
    bool _trgrt6I = 0;
    bool _trgrt5 = 0;
    bool _trgrt5I = 0;
    bool _tim1I = 0;
    bool _tim1O = 0;
    unsigned long _tim1P = 0UL;
    bool _bounseInputD4S = 0;
    bool _bounseInputD4O = 0;
    unsigned long _bounseInputD4P = 0UL;
    bool _gen1I = 0;
    bool _gen1O = 0;
    unsigned long _gen1P = 0UL;
    bool _changeNumber1_Out = 0;
    int _changeNumber1_OLV;
    bool _trgrt4 = 0;
    bool _trgrt4I = 0;
    bool _trgs1 = 0;
    bool _trgrt3 = 0;
    bool _trgrt3I = 0;
    bool _trgrt1 = 0;
    bool _trgrt1I = 0;
    bool _count1I = 0;
    int _count1P = 0;
    bool _trgrt2 = 0;
    bool _trgrt2I = 0;
    bool _gen2I = 0;
    bool _gen2O = 0;
    unsigned long _gen2P = 0UL;
    bool _trgt1 = 0;
    bool _trgt1I = 0;
    void setup()
    {
    pinMode(4, INPUT);
    digitalWrite(4, HIGH);
    pinMode(9, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(13, OUTPUT);

    _bounseInputD4O =  digitalRead(4);
    tm1637_62193421_1.set();
    tm1637_62193421_1.init();
    }
    void loop()
    {int _tempVariable_int;// здесь ошибка ============================================

    bool  _bounceInputTmpD4 =  (digitalRead (4));

    if (_bounseInputD4S)
        {
         if (millis() >= (_bounseInputD4P + 40))
             {_bounseInputD4O= _bounceInputTmpD4; _bounseInputD4S=0;}
         }
    else
        {
         if (_bounceInputTmpD4 != _bounseInputD4O )
             {_bounseInputD4S=1; _bounseInputD4P = millis();}
          }

    //Плата:1
    if (!(_bounseInputD4O)) { if (_trgrt5I) { _trgrt5 = 0;} else {_trgrt5 = 1; _trgrt5I = 1;} } else {_trgrt5 = 0; _trgrt5I = 0;};
    bool  _tmp1 = ( (_trgrt5) || (( (_gtv6) && (_gtv7) )) );
    if (_tmp1)  { if (! _trgt1I) _trgt1 = ! _trgt1; }
    _trgt1I = _tmp1;
    _gtv6 = _trgt1;
    digitalWrite(6, !(_gtv6));
    digitalWrite(5, _gtv6);
    digitalWrite(13, ( (_gtv6) && (_gtv4) ));
    if (_gtv6) { if (! _gen2I) { _gen2I = 1; _gen2O = 1; _gen2P = millis(); } } else { _gen2I = 0 ; _gen2O= 0;}
    if (_gen2I) {  if ( _isTimer ( _gen2P , 30000 )) { _gen2P = millis(); _gen2O = ! _gen2O;}}
    _gtv8 = _gen2O;

    //Плата:2
    if (!(0)) { if (! _gen1I) { _gen1I = 1; _gen1O = 1; _gen1P = millis(); } } else { _gen1I = 0 ; _gen1O= 0;}
    if (_gen1I) {  if ( _isTimer ( _gen1P , 500 )) { _gen1P = millis(); _gen1O = ! _gen1O;}}
    _gtv4 = _gen1O;
    if (_gen1O) { if (_trgrt1I) { _trgrt1 = 0;} else {_trgrt1 = 1; _trgrt1I = 1;} } else {_trgrt1 = 0; _trgrt1I = 0;};
    if (_trgrt1) {
    _gtv5 = (map(( (analogRead (0))), (0), (1023), (0), (300)));
    }
    if (_changeNumber1_Out) {_changeNumber1_Out = 0;} else {_tempVariable_int = _gtv5;
    if (_tempVariable_int != _changeNumber1_OLV) {_changeNumber1_OLV = _tempVariable_int; _changeNumber1_Out = 1;}
    }
    if (!(0)) { if (_trgrt2I) { _trgrt2 = 0;} else {_trgrt2 = 1; _trgrt2I = 1;} } else {_trgrt2 = 0; _trgrt2I = 0;};
    if (_gtv7) { if (_trgrt3I) { _trgrt3 = 0;} else {_trgrt3 = 1; _trgrt3I = 1;} } else {_trgrt3 = 0; _trgrt3I = 0;};
    if(( (( (!(_gtv6)) && (_changeNumber1_Out) )) || (_trgrt2) || (_trgrt3) )) _count1P = (_gtv5);
    if (( (!((_gtv5) < (1))) && (_gtv8) ))
       {
       if (! _count1I)
          {
           _count1P = _count1P1;
           _count1I = 1;
          }
       }
    else
       {
       _count1I=0;
       }
    if ((_count1P) < (1)) { if (_trgrt4I) { _trgrt4 = 0;} else {_trgrt4 = 1; _trgrt4I = 1;} } else {_trgrt4 = 0; _trgrt4I = 0;};
    _gtv7 = _trgrt4;
    _gtv1 = _count1P;

    //Плата:3
    //Наименование:Дисплей
    _gtv2 = ((_gtv1)/(60))*(60);
    Hours_62193421_1 = (_gtv1)/(60);
    Mins_62193421_1 = (_gtv1)(_gtv2);
    Sec_62193421_1 = ( (_gtv4) && (_gtv6) );
    Brightness_62193421_1 = 5;
    TimeDisp_62193421_1[0] = Hours_62193421_1 / 10;
    TimeDisp_62193421_1[1] = Hours_62193421_1 % 10;
    TimeDisp_62193421_1[2] = Mins_62193421_1 / 10;
    TimeDisp_62193421_1[3] = Mins_62193421_1 % 10;
    if ( Sec_62193421_1 ) tm1637_62193421_1.point(HIGH); else tm1637_62193421_1.point(LOW);
    tm1637_62193421_1.set(Brightness_62193421_1);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
    tm1637_62193421_1.display(TimeDisp_62193421_1);

    //Плата:4
    if(_gtv6) _trgs1 = 1;
    if(_gtv9) _trgs1 = 0;
    if (( (_trgs1) && (_gtv7) )) { if (_trgrt6I) { _trgrt6 = 0;} else {_trgrt6 = 1; _trgrt6I = 1;} } else {_trgrt6 = 0; _trgrt6I = 0;};
    _gtv9 = _trgrt6;
    if(_trgrt6) {_tim1O = 1; _tim1I = 1;} else { if(_tim1I) {_tim1I = 0; _tim1P = millis();} else { if (_tim1O) {if ( _isTimer(_tim1P, 5000)) _tim1O = 0;}}}
    digitalWrite(9, ( (_gtv4) && (_tim1O) ));

    }
    bool _isTimer(unsigned long startTime, unsigned long period )
      {
      unsigned long currentTime;
    currentTime = millis();
    if (currentTime>= startTime) {return (currentTime>=(startTime + period));} else {return (currentTime >=(4294967295startTime+period));}
      }

       flag = 0
         }

         

          if(digitalRead(butSState)==LOW&&flag==1)

            flag=0;

         }

    }

    выдаёт ошибку
    Arduino: 1.8.5 (Windows 7), Плата:»Arduino Nano, ATmega328P»

    C:UsersТатьянаDocumentsArduinosketch_mar22asketch_mar22a.ino: In function ‘void loop()’:

    sketch_mar22a:63: error: a function-definition is not allowed here before ‘{‘ token

    sketch_mar22a:76: error: a function-definition is not allowed here before ‘{‘ token

    sketch_mar22a:184: error: expected ‘}’ at end of input

    sketch_mar22a:184: error: expected ‘}’ at end of input

    exit status 1
    a function-definition is not allowed here before ‘{‘ token

    Этот отчёт будет иметь больше информации с
    включенной опцией Файл -> Настройки ->
    «Показать подробный вывод во время компиляции»

    заранее спасибо!!!

    Последнее редактирование: 23 мар 2018

  2. Дважды
    void loop объявлена
    И внутри первой loop торчит объявление void setup.

    Разберите внимательно всю эту кашу. И читайте что говорит компилятор.

  3. Убрать лишнее объявление
    void loop().
    И не повторять эту ошибку.

  4. После функции

    bool _isTimer(unsigned long startTime, unsigned long period )
    {
      unsigned long currentTime;
      currentTime = millis();
      if (currentTime>= startTime)
      {
        return (currentTime>=(startTime + period));
      } else
      {
        return (currentTime >=(4294967295startTime+period));
      }
    }
     

    Идёт ещё какой то код.

    Такое ощущение что ты втыкал куски кода куда попало.

  5. а тут что ??????

    #include <TM1637.h>
    int Hours_62193421_1;
    int Mins_62193421_1;
    bool Sec_62193421_1;
    int Brightness_62193421_1;
    TM1637 tm1637_62193421_1(7 , 8);
    int8_t TimeDisp_62193421_1[] = {0x00,0x00,0x00,0x00};
    int _gtv1;
    int _gtv2;
    bool _gtv4;
    int _gtv5;
    bool _gtv6;
    bool _gtv7;
    bool _gtv8;
    bool _gtv9;
    bool _trgrt6 = 0;
    bool _trgrt6I = 0;
    bool _trgrt5 = 0;
    bool _trgrt5I = 0;
    bool _tim1I = 0;
    bool _tim1O = 0;
    unsigned long _tim1P = 0UL;
    bool _bounseInputD4S = 0;
    bool _bounseInputD4O = 0;
    unsigned long _bounseInputD4P = 0UL;
    bool _gen1I = 0;
    bool _gen1O = 0;
    unsigned long _gen1P = 0UL;
    bool _changeNumber1_Out = 0;
    int _changeNumber1_OLV;
    bool _trgrt4 = 0;
    bool _trgrt4I = 0;
    bool _trgs1 = 0;
    bool _trgrt3 = 0;
    bool _trgrt3I = 0;
    bool _trgrt1 = 0;
    bool _trgrt1I = 0;
    bool _count1I = 0;
    int _count1P = 0;
    bool _trgrt2 = 0;
    bool _trgrt2I = 0;
    bool _gen2I = 0;
    bool _gen2O = 0;
    unsigned long _gen2P = 0UL;
    bool _trgt1 = 0;
    bool _trgt1I = 0;
    const int butSPin = 2;
    int butSState = 0;
    void setup()
    {
    pinMode(4, INPUT);
    digitalWrite(4, HIGH);
    pinMode(9, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(13, OUTPUT);

    _bounseInputD4O =  digitalRead(4);
    tm1637_62193421_1.set();
    tm1637_62193421_1.init();
    pinMode (butSPin , INPUT);

    }

    int flag=0;

    void loop(){
    if(digitalRead(butSState)==HIGH&&flag==0)
    {

    int _tempVariable_int;

    bool  _bounceInputTmpD4 =  (digitalRead (4));

    if (_bounseInputD4S)
        {
         if (millis() >= (_bounseInputD4P + 40))
             {_bounseInputD4O= _bounceInputTmpD4; _bounseInputD4S=0;}
         }
    else
        {
         if (_bounceInputTmpD4 != _bounseInputD4O )
             {_bounseInputD4S=1; _bounseInputD4P = millis();}
          }

    //Плата:1
    if (!(_bounseInputD4O)) { if (_trgrt5I) { _trgrt5 = 0;} else {_trgrt5 = 1; _trgrt5I = 1;} } else {_trgrt5 = 0; _trgrt5I = 0;};
    bool  _tmp1 = ( (_trgrt5) || (( (_gtv6) && (_gtv7) )) );
    if (_tmp1)  { if (! _trgt1I) _trgt1 = ! _trgt1; }
    _trgt1I = _tmp1;
    _gtv6 = _trgt1;
    digitalWrite(6, !(_gtv6));
    digitalWrite(5, _gtv6);
    digitalWrite(13, ( (_gtv6) && (_gtv4) ));
    if (_gtv6) { if (! _gen2I) { _gen2I = 1; _gen2O = 1; _gen2P = millis(); } } else { _gen2I = 0 ; _gen2O= 0;}
    if (_gen2I) {  if ( _isTimer ( _gen2P , 30000 )) { _gen2P = millis(); _gen2O = ! _gen2O;}}
    _gtv8 = _gen2O;

    //Плата:2
    if (!(0)) { if (! _gen1I) { _gen1I = 1; _gen1O = 1; _gen1P = millis(); } } else { _gen1I = 0 ; _gen1O= 0;}
    if (_gen1I) {  if ( _isTimer ( _gen1P , 500 )) { _gen1P = millis(); _gen1O = ! _gen1O;}}
    _gtv4 = _gen1O;
    if (_gen1O) { if (_trgrt1I) { _trgrt1 = 0;} else {_trgrt1 = 1; _trgrt1I = 1;} } else {_trgrt1 = 0; _trgrt1I = 0;};
    if (_trgrt1) {
    _gtv5 = (map(( (analogRead (0))), (0), (1023), (0), (300)));
    }
    if (_changeNumber1_Out) {_changeNumber1_Out = 0;} else {_tempVariable_int = _gtv5;
    if (_tempVariable_int != _changeNumber1_OLV) {_changeNumber1_OLV = _tempVariable_int; _changeNumber1_Out = 1;}
    }
    if (!(0)) { if (_trgrt2I) { _trgrt2 = 0;} else {_trgrt2 = 1; _trgrt2I = 1;} } else {_trgrt2 = 0; _trgrt2I = 0;};
    if (_gtv7) { if (_trgrt3I) { _trgrt3 = 0;} else {_trgrt3 = 1; _trgrt3I = 1;} } else {_trgrt3 = 0; _trgrt3I = 0;};
    if(( (( (!(_gtv6)) && (_changeNumber1_Out) )) || (_trgrt2) || (_trgrt3) )) _count1P = (_gtv5);
    if (( (!((_gtv5) < (1))) && (_gtv8) ))
       {
       if (! _count1I)
          {
           _count1P = _count1P1;
           _count1I = 1;
          }
       }
    else
       {
       _count1I=0;
       }
    if ((_count1P) < (1)) { if (_trgrt4I) { _trgrt4 = 0;} else {_trgrt4 = 1; _trgrt4I = 1;} } else {_trgrt4 = 0; _trgrt4I = 0;};
    _gtv7 = _trgrt4;
    _gtv1 = _count1P;

    //Плата:3
    //Наименование:Дисплей
    _gtv2 = ((_gtv1)/(60))*(60);
    Hours_62193421_1 = (_gtv1)/(60);
    Mins_62193421_1 = (_gtv1)(_gtv2);
    Sec_62193421_1 = ( (_gtv4) && (_gtv6) );
    Brightness_62193421_1 = 5;
    TimeDisp_62193421_1[0] = Hours_62193421_1 / 10;
    TimeDisp_62193421_1[1] = Hours_62193421_1 % 10;
    TimeDisp_62193421_1[2] = Mins_62193421_1 / 10;
    TimeDisp_62193421_1[3] = Mins_62193421_1 % 10;
    if ( Sec_62193421_1 ) tm1637_62193421_1.point(HIGH); else tm1637_62193421_1.point(LOW);
    tm1637_62193421_1.set(Brightness_62193421_1);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
    tm1637_62193421_1.display(TimeDisp_62193421_1);

    //Плата:4
    if(_gtv6) _trgs1 = 1;
    if(_gtv9) _trgs1 = 0;
    if (( (_trgs1) && (_gtv7) )) { if (_trgrt6I) { _trgrt6 = 0;} else {_trgrt6 = 1; _trgrt6I = 1;} } else {_trgrt6 = 0; _trgrt6I = 0;};
    _gtv9 = _trgrt6;
    if(_trgrt6) {_tim1O = 1; _tim1I = 1;} else { if(_tim1I) {_tim1I = 0; _tim1P = millis();} else { if (_tim1O) {if ( _isTimer(_tim1P, 5000)) _tim1O = 0;}}}
    //  here   erorr   выше строка

    //===============================================
    digitalWrite(9, ( (_gtv4) && (_tim1O) ));

    }
    bool _isTimer(unsigned long startTime, unsigned long period )
      {
      unsigned long currentTime;
    currentTime = millis();
    if (currentTime>= startTime) {return (currentTime>=(startTime + period));} else {return (currentTime >=(4294967295startTime+period));}
      }

       flag = 0
         }

         

          if(digitalRead(butSState)==LOW&&flag==1)

            flag=0;

         }

    }

    вот ошибка
    Arduino: 1.8.5 (Windows 7), Плата:»Arduino Nano, ATmega328P»

    C:UsersТатьянаDocumentsArduinosketch_mar22asketch_mar22a.ino: In function ‘void loop()’:

    sketch_mar22a:100: error: ‘_isTimer’ was not declared in this scope

    sketch_mar22a:105: error: ‘_isTimer’ was not declared in this scope

    sketch_mar22a:154: error: ‘_isTimer’ was not declared in this scope

    sketch_mar22a:162: error: a function-definition is not allowed here before ‘{‘ token

    sketch_mar22a:180: error: expected ‘}’ at end of input

    exit status 1
    ‘_isTimer’ was not declared in this scope

    Этот отчёт будет иметь больше информации с
    включенной опцией Файл -> Настройки ->
    «Показать подробный вывод во время компиляции»

  6. Всё написано в сообщениях об ошибке

    : ‘_isTimer’ was not declared in this scope

    Функции и переменные нужно объявлять до их использования, а не где попало.

  7. В строке 162 какая то функция объявлена неожиданно

    sketch_mar22a:162: error: a function-definition is not allowed here before ‘{‘

  8. И вероятно фигурные скобки не сбалансированы. Где то не хватает закрывающей скобки.

    Понять это можно когда файл с программой весь прочитан, а скобки так и нет.

    sketch_mar22a:180: error: expected ‘}’ at end of input

  9. наконец то

    компиляция завершена
    скетч использует 4360 байт

  10. было ооочень много ошибок

  11. что поделаешь мне всего 12 лет:)

  12. Чаще скетч проверяй компилятором по ходу написания.
    Поменял строчку. Проверил. Так гораздо проще ошибку найти.

  13. eg12
    В этом фрагменте кода:

    currentTime = millis();
      if (currentTime>= startTime)
      {

    значение startTime может находится в будущем? Иначе проверка не имеет смысла.

    Для общего развития, советую ознакомиться.

How to fix expected primary expression beforeThe expected primary expression before occurs due to syntax errors. It usually has a character or a keyword at the end that clarifies the cause. Here you’ll get access to the most common syntax mistakes that throw the same error.

Continue reading to see where you might be getting wrong and how you can solve the issue.

Contents

  • Why Does the Expected Primary Expression Before Occur?
    • – You Are Specifying the Data Type With Function Argument
    • – The Wrong Type of Arguments
    • – Issue With the Curly Braces Resulting in Expected Primary Expression Before }
    • – The Parenthesis Following the If Statement Don’t Contain an Expression
  • How To Fix the Given Error?
    • – Remove the Data Type That Precedes the Function Argument
    • – Pass the Arguments of the Expected Data Type
    • – Ensure The Equal Number of Opening and Closing Curly Brackets
    • – Add an Expression in the If Statement Parenthesis
  • FAQ
    • – What Does It Mean When the Error Says “Expected Primary Expression Before Int” in C?
    • – What Is a Primary Expression in C Language?
    • – What Are the Types of Expressions?
  • Conclusion

Why Does the Expected Primary Expression Before Occur?

The expected primary expression before error occurs when your code doesn’t follow the correct syntax. The mistakes pointed out below are the ones that often take place when you are new to programming. However, a programmer in hurry might make the same mistakes.

So, here you go:

– You Are Specifying the Data Type With Function Argument

If your function call contains the data type along with the argument, then you’ll get an error.

Here is the problematic function call:

int addFunction(int num1, int num2)
{
int sum;
sum = num1 + num2;
return sum;
}
int main()
{
int result = addFunction(int 20, int 30);
}

– The Wrong Type of Arguments

Passing the wrong types of arguments can result in the same error. You can not pass a string to a function that accepts an argument of int data type.

int main()
{
int result = addFunction(string “cat”, string “kitten”);
}

– Issue With the Curly Braces Resulting in Expected Primary Expression Before }

Missing a curly bracket or adding an extra curly bracket usually results in the mentioned error.

– The Parenthesis Following the If Statement Don’t Contain an Expression

If the parenthesis in front of the if statement doesn’t contain an expression or the result of an expression, then the code won’t run properly. Consequently, you’ll get the stated error.

How To Fix the Given Error?

You can fix the “expected primary-expression before” error by using the solutions given below:

– Remove the Data Type That Precedes the Function Argument

Remove the data type from the parenthesis while calling a function to solve the error. Here is the correct way to call a function:

int main()
{
int result = addFunction(30, 90);
}

– Pass the Arguments of the Expected Data Type

Double-check the function definition and pass the arguments of the type that matches the data type of the parameters. It will ensure that you pass the correct arguments and kick away the error.

– Ensure The Equal Number of Opening and Closing Curly Brackets

Your program must contain an equal number of opening and closing curly brackets. Begin with carefully observing your code to see where you are doing the mistake.

– Add an Expression in the If Statement Parenthesis

The data inside the parenthesis following the if statement should be either an expression or the result of an expression. Even adding either true or false will solve the issue and eliminate the error.

FAQ

You can view latest topics and suggested topics that’ll help you as a new programmer.

– What Does It Mean When the Error Says “Expected Primary Expression Before Int” in C?

The “expected primary expression before int” error means that you are trying to declare a variable of int data type in the wrong location. It mostly happens when you forget to terminate the previous statement and proceed with declaring another variable.

– What Is a Primary Expression in C Language?

A primary expression is the basic element of a complex expression. The identifiers, literals, constants, names, etc are considered primary expressions in the C programming language.

– What Are the Types of Expressions?

The different types of expressions include arithmetic, character, and logical or relational expressions. An arithmetic expression returns an arithmetic value. A character expression gives back a character value. Similarly, a logical value will be the output of a logical or relational expression.

Conclusion

The above error revolves around syntax mistakes and can be solved easily with a little code investigation. The noteworthy points depicting the solutions have been written below to help you out in removing the error:

  • Never mention the data type of parameters while calling a function
  • Ensure that you pass the correct type of arguments to the given function
  • You should not miss a curly bracket or add an extra one
  • The if statement should always be used with the expressions, expression results, true, or false

What is expected primary expression before errorThe more you learn the syntax and practice coding, the more easily you’ll be able to solve the error.

  • Author
  • Recent Posts

Position is Everything

Position Is Everything: Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL.

Position is Everything

Понравилась статья? Поделить с друзьями:
  • Error exists in required projects eclipse
  • Error exist in the active configuration of project
  • Error exfat file system is not found
  • Error execution phase kubelet start error uploading crisocket timed out waiting for the condition
  • Error expected nested name specifier before system