Expected unqualified id before string constant ошибка

I’m currently writing a C++ application which implements an Oscillator in conjuction with math.h. The code I have should work fine for the application (trying to compile an object file), bu I’m getting a compiler error most likely having to do with syntax/etc; I think it has something to do with namespace. The error:

Terminal Output:

User-Name-Macbook-Pro:Synth Parts UserName$ make
g++ -o Oscillators.o -c -I. Oscillators.cpp -c
In file included from Oscillators.cpp:2:
/usr/include/math.h:41: error: expected unqualified-id before string constant
In file included from /usr/include/c++/4.2.1/bits/locale_facets.tcc:42,
             from /usr/include/c++/4.2.1/locale:46,
             from /usr/include/c++/4.2.1/bits/ostream.tcc:46,
             from /usr/include/c++/4.2.1/ostream:635,
             from /usr/include/c++/4.2.1/iostream:45,
             from Oscillators.cpp:4:
/usr/include/c++/4.2.1/typeinfo:41: error: expected declaration before end of line
make: *** [Oscillators.o] Error 1

Oscillators.cpp

#include "Oscillators.h"
#include <math.h>
#include <vector>
#include <iostream>

#define TWOPI (6.2831853072)

using namespace std;

oscillator(int srate = 44100, int tabsize = 8192, double freq = 200) // Default to output 200Hz Sine Wave
{
    if(srate <= 0) {
        cout << "Error: sample rate must be positive" << endl;
        return;
    }
    sizeovrsr_ = (double)tabsize / (double)srate
    if(freq < 20 || freq > 20000) {
        cout << "Error: frequency is out of audible range" << endl;
        return;
    }
    curfreq_ = freq;
    curphase_ = 0.0 // Not out of one, out of tabsize
    incr_ = curfreq * sizeovrsr_;
    for(int i = 0; i < tabsize; i++) {
        gtable.push_back(sin((i*TWOPI)/(double)tabsize));
    }
    gtable.push_back(gtable[0]);
}

void print_table()
{
    vector<double>::size_type i;
    for(i = 0; i < gtable.size(); i++)
        cout << gtable[i] << "n";
    cout << endl;
}

Oscillators.h

#ifndef GUARD_OSCILLATORS_H
#define GUARD_OSCILLATORS_H
#include <vector>

class oscillator {
public:
    /*
    void fill_sine(); // Will change the table to a sine wave
    void fill_square(); // Will change the table to a square wave
    void fill_sawtooth(); // Will change the table to a sawtooth wave
    void fill_triangle(); // Will change the table to a triangle wave
    double tick(double freq); // Will output the current sample and update the phase
    */
    void print_table(); // Will print all table values to standard output
    oscillator(int srate = 44100, double freq = 200, int tabsize = 8192);
private:
    double sizeovrsr_; // Will be set at initialization and will determine phase increase for tick func
    double curphase_;
    double curfreq_; // if the freq sent to a tick function doesn't match the current tick, it will be reset;
    double incr_;
    std::vector<double> gtable_; // Will contain a wavetable with a guard point.
}
#endif

I’ve seen other suggestions that mention using g++ -Wall -g but I’m not sure that that is the problem, and that there is something else going on here.

Any help would be much appreciated! Thanks!!

Arduino Forum

Loading

I have the same issue trying to merge C with c++here are the errors i get, can someone please help

warning: unused variable ‘ret’ [-Wunused-variable]
int ret;
^~~
Compiling .piobuildesp-wrover-kitcbortinycborsrccborencoder.o
Compiling .piobuildesp-wrover-kitcbortinycborsrccborparser_dup_string.o
Compiling .piobuildesp-wrover-kitcbortinycborsrccborparser.o
Compiling .piobuildesp-wrover-kitcbortinycborsrccborpretty.o
Compiling .piobuildesp-wrover-kitcbortinycborsrccbortojson.o
Compiling .piobuildesp-wrover-kitcbortinycborsrccborvalidation.o
Compiling .piobuildesp-wrover-kitcbortinycborsrcopen_memstream.o
Compiling .piobuildesp-wrover-kitcoaplibcoapsrcaddress.o
Compiling .piobuildesp-wrover-kitcoaplibcoapsrcasync.o
Compiling .piobuildesp-wrover-kitcoaplibcoapsrcblock.o
Compiling .piobuildesp-wrover-kitcoaplibcoapsrccoap_asn1.o
Compiling .piobuildesp-wrover-kitcoaplibcoapsrccoap_cache.o
Compiling .piobuildesp-wrover-kitcoaplibcoapsrccoap_debug.o
In file included from src/wisekey_Http_Request_Manager.cpp:60:
include/wisekey_Tools.h: In function ‘void setup()’:
include/wisekey_Tools.h:10:8: error: expected unqualified-id before string constant
extern «C»
^~~
In file included from lib/wolfssl/src/wolfssl/wolfcrypt/types.h:34,
from lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:37,
from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/settings.h:52:12: error: expected unqualified-id before string constant
extern «C» {
^~~
In file included from lib/wolfssl/src/wolfssl/wolfcrypt/types.h:35,
from lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:37,
from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/wc_port.h:33:12: error: expected unqualified-id before string constant
extern «C» {
^~~
In file included from lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:37,
from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/types.h:38:16: error: expected unqualified-id before string constant
extern «C» {
^~~
In file included from lib/wolfssl/src/wolfssl/wolfcrypt/tfm.h:47,
from lib/wolfssl/src/wolfssl/wolfcrypt/integer.h:39,
from lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:46,
from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/random.h:45:12: error: expected unqualified-id before string constant
extern «C» {
^~~
In file included from lib/wolfssl/src/wolfssl/wolfcrypt/integer.h:39,
from lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:46,
from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/tfm.h:50:12: error: expected unqualified-id before string constant
extern «C» {
^~~
In file included from lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:61,
from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/sha.h:60:12: error: expected unqualified-id before string constant
extern «C» {
^~~
In file included from lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:64,
from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/md5.h:42:12: error: expected unqualified-id before string constant
extern «C» {
^~~
In file included from lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:67,
from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/asn_public.h:39:12: error: expected unqualified-id before string constant
extern «C» {
^~~
In file included from include/wisekey_Crypto_Tools.h:10,
from src/wisekey_Http_Request_Manager.cpp:61:
lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:74:12: error: expected unqualified-id before string constant
extern «C» {
^~~
lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:2494:52: error: ‘word32’ has not been declared
WOLFSSL_LOCAL int DecodeAsymKey(const byte* input, word32* inOutIdx,
^~~~~~
lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:2495:5: error: ‘word32’ has not been declared
word32 inSz, byte* privKey, word32* privKeyLen, byte* pubKey,
^~~~~~
lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:2495:33: error: ‘word32’ has not been declared
word32 inSz, byte* privKey, word32* privKeyLen, byte* pubKey,
^~~~~~
lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:2496:5: error: ‘word32’ has not been declared
word32* pubKeyLen, int keyType);
Compiling .piobuildesp-wrover-kitcoaplibcoapsrccoap_time.o
^~~~~~
lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:2500:54: error: ‘word32’ has not been declared
WOLFSSL_LOCAL int SetAsymKeyDer(const byte* privKey, word32 privKeyLen,
^~~~~~
lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:2501:25: error: ‘word32’ has not been declared
const byte* pubKey, word32 pubKeyLen, byte* output, word32 outLen,
^~~~~Compiling .piobuildesp-wrover-kitcoaplibcoapsrcencode.o
~
lib/wolfssl/src/wolfssl/wolfcrypt/asn.h:2501:57: error: ‘word32’ has not been declared
const byte* pubKey, word32 pubKeyLen, byte* output, word32 outLen,
^~~~~~
In file included from include/wisekey_Crypto_Tools.h:11,
from src/wisekey_Http_Request_Manager.cpp:61:
Compiling .piobuildesp-wrover-kitcoaplibcoapsrcmem.o
lib/wolfssl/src/wolfssl/wolfcrypt/aes.h:126:12: error: expected unqualified-id before string constant
extern «C» {
Compiling .piobuildesp-wrover-kitcoaplibcoapsrcnet.o
^~~
In file included from src/wisekey_Http_Request_Manager.cpp:61:
include/wisekey_Crypto_Tools.h:14:8: error: expected unqualified-id before string constant
extern «C»
Compiling .piobuildesp-wrover-kitcoaplibcoapsrcoption.o
^~~
src/wisekey_Http_Request_Manager.cpp:69:1: error: a function-definition is not allowed here before ‘{‘ token
{
^
src/wisekey_Http_Request_Manager.cpp:91:1: error: a function-definition is not allowed here before ‘{‘ token
{
^
src/wisekey_Http_Request_Manager.cpp:137:1: error: a function-definition is not allowed here before ‘{‘ token
{
^
src/wisekey_Http_Request_Manager.cpp:164:1: error: a function-definition is not allowed here before ‘{‘ token
{
^
src/wisekey_Http_Request_Manager.cpp:416:11: error: ‘sockfd’ was not declared in this scope
close(sockfd);
^~~~~~
src/wisekey_Http_Request_Manager.cpp:416:11: note: suggested alternative: ‘socket’
close(sockfd);
^~~~~~
socket
src/wisekey_Http_Request_Manager.cpp:418:12: error: ‘response’ was not declared in this scope
return response;
^~~~~~~~
src/wisekey_Http_Request_Manager.cpp:418:12: note: suggested alternative: ‘revoke’
return response;
^~~~~~~~
revoke
src/wisekey_Http_Request_Manager.cpp:418:12: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
src/wisekey_Http_Request_Manager.cpp: In function ‘char* findValuebyName(char*, char*)’:
src/wisekey_Http_Request_Manager.cpp:448:27: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
value = malloc(strlen(strseparated) + 2);
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:456:12: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
return «null»;
^~~~~~
In file included from src/wisekey_Http_Request_Manager.cpp:59:
src/wisekey_Http_Request_Manager.cpp: In function ‘char* getAccessTokenFromInes(char*)’:
include/wisekey_ZTP_settings.h:28:22: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define IOT_BASE_URL «trustcenter.certifyiddemo.com»
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:461:18: note: in expansion of macro ‘IOT_BASE_URL’
char host = IOT_BASE_URL;
^~~~~~~~~~~~
include/wisekey_ZTP_settings.h:29:25: warning: ISO C++ forbids converting a string constant to ‘char
‘ [-Wwrite-strings]
#define IOT_PATH_PREFIX «/iotcms/api»
^~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:462:24: note: in expansion of macro ‘IOT_PATH_PREFIX’
char pathPrefix = IOT_PATH_PREFIX;
^~~~~~~~~~~~~~~
include/wisekey_ZTP_settings.h:30:32: warning: ISO C++ forbids converting a string constant to ‘char
‘ [-Wwrite-strings]
#define IOT_API_GET_AUTH_TOKEN «/auth»
^~~~~~~
src/wisekey_Http_Request_Manager.cpp:464:23: note: in expansion of macro ‘IOT_API_GET_AUTH_TOKEN’
char apiSuffix = IOT_API_GET_AUTH_TOKEN;
^~~~~~~~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:469:23: error: invalid conversion from ‘void
‘ to ‘char*’ [-fpermissive]
char api = malloc(str_Size);
~~~~~~^~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:473:21: error: ‘generateHttpHeader’ was not declared in this scope
char headers = generateHttpHeader(host, api, «», NULL);
^~~~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:477:16: error: ‘http_POSTrequest’ was not declared in this scope
response = http_POSTrequest(host, api, headers, NULL);
^~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:479:65: warning: ISO C++ forbids converting a string constant to ‘char
‘ [-Wwrite-strings]
char accessToken = findValuebyName(response, «access_token»);
^
In file included from src/wisekey_Http_Request_Manager.cpp:59:
src/wisekey_Http_Request_Manager.cpp: In function ‘char
getCertificateFromInes(char
, char*, char*, char*, char*, char*, char*)’:
include/wisekey_ZTP_settings.h:28:22: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
#define IOT_BASE_URL «trustcenter.certifyiddemo.com»
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:490:18: note: in expansion of macro ‘IOT_BASE_URL’
char host = IOT_BASE_URL;
^~~~~~~~~~~~
include/wisekey_ZTP_settings.h:29:25: warning: ISO C++ forbids converting a string constant to ‘char
‘ [-Wwrite-strings]
#define IOT_PATH_PREFIX «/iotcms/api»
^~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:491:24: note: in expansion of macro ‘IOT_PATH_PREFIX’
char pathPrefix = IOT_PATH_PREFIX;
^~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:496:23: error: invalid conversion from ‘void
‘ to ‘char*’ [-fpermissive]
char *api = malloc(str_Size);
~~~~~~^~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:499:18: error: ‘generateCSRBody’ was not declared in this scope
char body = generateCSRBody(templateId, devicename, CSR, country, 30);
^~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:500:21: error: ‘generateHttpHeader’ was not declared in this scope
char headers = generateHttpHeader(host, api, body, accessToken);
^~~~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:504:16: error: ‘http_POSTrequest’ was not declared in this scope
response = http_POSTrequest(host, api, headers, body);
^~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:506:31: error: invalid conversion from ‘void
‘ to ‘char
‘ [-fpermissive]
char responseCpy = malloc(strlen(response) + 1);
~~~~~~^~~~~~~~~~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:509:59: warning: ISO C++ forbids converting a string constant to ‘char
‘ [-Wwrite-strings]
char returncode = findValuebyName(responseCpy, «code»);
^
src/wisekey_Http_Request_Manager.cpp:513:31: warning: ISO C++ forbids converting a string constant to ‘char
‘ [-Wwrite-strings]
char issuedCertificate = «null»;
^~~~~~
src/wisekey_Http_Request_Manager.cpp:517:71: warning: ISO C++ forbids converting a string constant to ‘char
‘ [-Wwrite-strings]
issuedCertificate = findValuebyName(responseCpy, «certificate»);
^
src/wisekey_Http_Request_Manager.cpp:521:24: error: ‘LOG_ERROR’ was not declared in this scope
WKEY_LOG_DEBUG(LOG_ERROR, «see INES response : rn%s», response);
^~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:521:24: note: suggested alternative: ‘SO_ERROR’
WKEY_LOG_DEBUG(LOG_ERROR, «see INES response : rn%s», response);
^~~~~~~~~
SO_ERROR
src/wisekey_Http_Request_Manager.cpp:521:9: error: ‘WKEY_LOG_DEBUG’ was not declared in this scope
WKEY_LOG_DEBUG(LOG_ERROR, «see INES response : rn%s», response);
^~~~~~~~~~~~~~
src/wisekey_Http_Request_Manager.cpp:521:9: note: suggested alternative: ‘ESP_LOG_DEBUG’
WKEY_LOG_DEBUG(LOG_ERROR, «see INES response : rn%s», response);
^~~~~~~~~~~~~~
ESP_LOG_DEBUG
*** [.piobuildesp-wrover-kitsrcwisekey_Http_Request_Manager.o] Error 1
================================================================================ [FAILED] Took 56.35 seconds ================================================================================

  • The terminal process «C:Usersobouamar.platformiopenvScriptsplatformio.exe ‘run’, ‘—target’, ‘upload’, ‘—target’, ‘monitor’, ‘—environment’, ‘esp-wrover-kit'» terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.

Модератор: Модераторы разделов

Erok

Сообщения: 7
ОС: Slackware 13.0

Решено: Ошибка в stdlib.h

Здравствуйте.
Qt Creator выдаёт ошибку в библиотеке stdlib.h. На Неё же в том же месте ругается и KDevelop. Ошибка следующая:
expected unqualified-id before string constant stdlib.h:35

В программе связывает со строкой
#include <stdlib.h>

Система Slackware 13.0.
Среды: Qt Creator 1.2.1, KDevelop 3.9.91

NickLion

Сообщения: 3408
Статус: аватар-невидимка
ОС: openSUSE Tumbleweed x86_64

Re: Решено: Ошибка в stdlib.h

Сообщение

NickLion » 20.12.2009 07:21

А если компилить просто g++, эта ошибка тоже есть? В 35 строчке стоит макрос, который заменяться должен на `extern «C» {`… т.е. ничего страшного. Покажите что-ли код Вашей программы. Думаю причина всё же в ней.

Erok

Сообщения: 7
ОС: Slackware 13.0

Re: Решено: Ошибка в stdlib.h

Сообщение

Erok » 20.12.2009 08:58

Ошибка только в main.cpp. Привожу его.

Код: Выделить всё

#include <QCoreApplication>
#include "lab3.h"
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <ctime>

using namespace std;

int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);
    //lab3 foo;
    desant t1;
    desant t2;
    desant t3(t2);
    desant t4(2, 3, 2, 1, 200);
    desant t5(6, 4, 1, 0, 145);
    jumper j;
    cout << "nFirst random object:";
    t1.show();
    cout << "nSecond random object:";
    t2.show();
    cout << "nCopy of second random object:";
    t3.show();
    cout << "n1st objact with parametrs:";
    t4.show();
    cout << "n2st objact with parametrs:";
    t5.show();
    cout << "nTis is the beter object";
    j.jshow();
    return 0;
}

Erok

Сообщения: 7
ОС: Slackware 13.0

Re: Решено: Ошибка в stdlib.h

Сообщение

Erok » 20.12.2009 10:03

Пустая строка есть. Приведу сразу все файлы.

stdafx.h:

Код: Выделить всё

// stdafx.h: включаемый файл для стандартных системных включаемых файлов
// или включаемых файлов для конкретного проекта, которые часто используются, но
// не часто изменяются
//

#pragma once

//#include "targetver.h"

#include <stdio.h>
//#include <tchar.h>



// TODO. Установите здесь ссылки на дополнительные заголовки, требующиеся для программы

lab3.h:

Код: Выделить всё

#ifndef lab3_lab3_H
#define lab3_lab3_H

#include <QtCore/QObject>

#pragma once

class desant
{
    int fkoordx;
    int fkoordy;
    int fname;
    int fvertspeed;
    int ftime;
    int fclass; //0 - десантник, 1 - боевая машина

public:
    desant();//конструктор по умолчанию
    desant(desant &a);//конструктор копирования
    desant(int akoordx, int akoordy, int avertspeed, int aclass, int aname);//конструктор с параметрами
    virtual int show();//вывод
    ~desant();
};

class jumper: public desant
{
  int jkoordx;
  int jkoordy;
  int jname;
  int jvertspeed;
  int jtime;

public:
    jumper();//конструктор по умолчанию
    virtual int jshow();//вывод
    ~jumper();
}

#endif // lab3_lab3_H

lab3.cpp:

Код: Выделить всё

#include "lab3.h"
#include "stdafx.h"
#include<stdlib.h>
#include<iostream>
using namespace std;

desant::desant()
{
    fkoordx=rand()%100;
    fkoordy=rand()%100;
    fname=rand();
    fvertspeed=1;
    fclass=rand()%2+1;
}
desant::desant(desant &a)
{
    fkoordx=a.fkoordx;
    fkoordy=a.fkoordy;
    fname=a.fname;
    fvertspeed=a.fvertspeed;
    fclass=a.fclass;
}
desant::desant(int akoordx, int akoordy, int avertspeed, int aclass, int aname)
{
    fkoordx=akoordx;
    fkoordy=akoordy;
    fname=rand()%aname+5;
    fvertspeed=avertspeed;
    fclass=aclass;
}
int desant::show()
{
    cout << "nPersonal number - " << fname << "n";
    if(fclass) cout << "This mann"; else cout << "This is warmachinen";
    cout << "X coordinate =" << fkoordx << "nY coordinate =" << fkoordy << "n";
    cout << "Vertical speed = " << fvertspeed << "n";
    return 0;
}
desant::~desant()
{
    cout << "DESTRUCTION";
}


jumper::jumper()
{
    jkoordx=rand()%100;
    jkoordy=rand()%100;
    jname=rand();
    jvertspeed=2;
}
int jumper::jshow()
{
    cout << "nPersonal number - " << jname << "n";
    cout << "This great(!) mann";
    cout << "X coordinate =" << jkoordx << "nY coordinate =" << jkoordy << "n";
    cout << "Vertical speed = " << jvertspeed << "n";
    return 0;
}

desant.h:

Код: Выделить всё

#pragma once

class desant
{
    int fkoordx;
    int fkoordy;
    int fname;
    int fvertspeed;
    int ftime;
    int fclass; //0 - десантник, 1 - боевая машина

public:
    desant();//конструктор по умолчанию
    desant(desant &a);//конструктор копирования
    desant(int akoordx, int akoordy, int avertspeed, int aclass, int aname);//конструктор с параметрами
    int show();//вывод
    ~desant();
};

The answer is: My code is missing a “;”
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
site:

back to the error of the line, found no problem.

error file: ptlogin2_api.h (line 22) : With the unqualified id before string constant

, in the middle of my CPP code (definitely not in the header file), a function XXX from the file ptlogin2_api.h,

#ifdef cplusplus
extern “C” {====== > Which line
#endif

turns out to be wrong?

I’m contains ptlogin2_api. H a recent include file
# include “dev_db_def. H” = = = = = = = = = = = = = = = = = = = “inside out of the question! Enumeration value definition ends with “; “missing. . Ptlogin_app_id.
# include “h”
# include “panel_auth. H”

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
there are multiple solutions can be found that the problem
1) add new code removed entirely, including the header files, to ensure that your code can be compiled through.
2) since there is no problem with the error, there is a problem near the code, or there is a problem with another file nearby. It is often the case that a file ends up missing the “;” , error in another file.
3) vi dev_insert.o is a versatile way to expand the code and see the state of the file when the compiler finally compiles the code. But it’s also the most complicated.

my dev_insert.o expand as follows:

45053 # 42 “.. H “
45054 enum _errorcode55 {
45056 DR_ERR_OK = 0,
45057 dr_err_validity = 1000,
45058 DR_ERR_LOGIN_STATE,
45059 DR_ERR_INSERT_DEV,
45060 DR_ERR_SELECT_DEV,
45061 DR_ERR_UPDATE_DEV,
45062 DR_ERR_ACTION_TYPE,
45063
45064}
45065 # 15 “dev_insert.cpp” 2
45066 # 1 “/data/home/nemo/code/isd_qzoneappbase_proj/base_class/base_lib/include/ptlogin_app_id.h” 1
45067 # 16 “dev_insert.cpp” 2
45068 # 1 “/data/home/ code/isd_qzoneappbase_proj/outerlib/panel_auth/include/panel_auth. H “1
45069
45070
45071
45072 # 1
45072 # 1 “/data/home/ code/isd_qzoneappbase_proj/base_class/extern_libs/tdev/include/toiw_all.h” 1
45073 # 5 “/data/home/ code/isd_qzoneappbase_proj/outerlib/panel_auth/include/panel_auth. H” 2
45074 # 1 “/data/home/nemo/code/isd_qzoneappbase_proj/base_class/extern_libs/tbase/include/tbase_all.h” 1
45075 # 6 “/data/home/ code/isd_qzoneappbase_proj/outerlib/panel_auth/include/panel_auth. H “2
45076 # 1 “/data/home/ code/isd_qzoneappbase_proj/outerlib/panel_auth/include/ptlogin2_api.h” 1
45077 # 25 “/ data/home/nemo/code/isd_qzoneappbase_proj/outerlib/panel_auth/include/ptlogin2_api. H”
45078 extern “C” {45079

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
For detailed debugging procedures, you can refer to a document in the mailbox and search for the keyword debugging using GCC.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
the GCC common error of the error, less often because;

expected unqualified-id before ****
generally occurs with the following prompt information as well as the unqualified ‘; ‘, and look up from the error to see if there is a semicolon missing at the end of the header file and at the end of the enumeration definition included above.

error: multiple types in one declaration
>
error: multiple types in one declaration
> In the second class, the last error.

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
type redefine link failure, if can’t find the cause of the code, may be written makefile have problems
the same. The two o file link, in this mistake. Depressed.
Make your own makefiles under GCC. Be very careful.

Понравилась статья? Поделить с друзьями:
  • Expected unqualified id before int ошибка
  • Expected to be a reference ошибка
  • Expected sub function or property ошибка
  • Exception processing message 0xc0000006 unexpected parameters ошибка
  • Exception occurs while importing 3d max revit ошибка