Error expected unqualified id before string constant extern c

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

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

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();
};

  • Forum
  • General C++ Programming
  • SOLVED: compiler giving error within mat

SOLVED: compiler giving error within math.h`

Hi —

This just cropped up: I’m getting an error:

error: expected unqualified-id before string constant

from within an architecture-specific math.h file. Here’s the offending code (it’s the extern statement):

1
2
3
#ifdef __cplusplus
extern "C" {
#endif 

Can someone help me figure this out? Thanks.

Last edited on

Where’s your closing brace?

Wazzak

The closing brace is way, way down the page, after a ton of other code. This is a standard distribution file from Apple, so I’m disinclined to think the problem is actually inside the file (unless my system drive corrupted somehow). I’m just wondering what might cause this to choke.

Thanks…

Have you declared any code or included any previous headers prior to including

<math.h>

?

Wazzak

Yes, I have. This is about six levels of includes deep, which is why I didn’t try to post all the code.

I found the problem. Improper syntax in a class declaration caused this red herring. (I love how C/C++ gives you error way, way downstream from the original problem. Sigh…)

Topic archived. No new replies allowed.

I’m getting these errors:

Code:

port.cpp: In member function ‘unsigned char Port::InByte(short unsigned int)’:
port.cpp:16: error: expected unqualified-id before string constant
port.cpp: In member function ‘void Port::OutByte(short unsigned int, unsigned char)’:
port.cpp:25: error: expected unqualified-id before string constant

Both errors point to the line:

Code:

extern «C»

Here is my port.h:

Code:

#ifndef PORT_H
#define PORT_H

class Port
{
public:
    Port();
    ~Port();
    unsigned char InByte(unsigned short _port);
    void OutByte(unsigned short _port, unsigned char _data);
private:
};

extern Port port;
#endif

and here is my port.cpp:

Code:

#include «port.h»

Port port;

Port::Port()
{
}

Port::~Port()
{
}

unsigned char Port::InByte(unsigned short _port)
{
    unsigned char rv;
    extern «C»
    {
        __asm__ __volatile__ («inb %1, %0» : «=a» (rv) : «dN» (_port));
    }
    return rv;
}

void Port::OutByte(unsigned short _port, unsigned char _data)
{
    extern «C»
    {
        __asm__ __volatile__ («outb %1, %0» : : «dN» (_port), «a» (_data));
    }
}

It’s being passed to gcc using

Code:

gpp -c port.cpp -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions

I don’t understand why it’s doing this. I’ve used C in C++ before.

Я разрабатываю игру для PSP, и компилятор жалуется на внешний «C» в заголовочном файле, и я не вижу ничего плохого в заголовочном файле.

Точное сообщение:

1>------ Build started: Project: PSP Pong, Configuration: Debug Win32 ------
1>  psp-g++ -I. -Ic:/pspsdk/psp/sdk/include -O2 -G0 -Wall  -I. -Ic:/pspsdk/psp/sdk/include -O2 -G0 -Wall  -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150   -c -o main.o main.cpp
1>  In file included from c:/pspsdk/psp/sdk/include/JRenderer.h (19) ,
1>                   from main.cpp (10) :
1>c:/pspsdk/lib/gcc/../../psp/include/gif_lib.h(20): error : expected unqualified-id before string constant
1>  c:pspsdkbinmake: *** [main.o] Error 1
1>  Press any key to continue . . . 
1>C:Program Files (x86)MSBuildMicrosoft.Cppv4.0Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "c:pspsdkbinvsmake.bat" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

JRenderer.h

// ———————————————— ————————————-

//
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
// 
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
// 
//-------------------------------------------------------------------------------------

#ifndef _JRENDERER_H_
#define _JRENDERER_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

#include <gif_lib.h>

#include "JTypes.h"


#ifdef WIN32

    #include <windows.h>

#else

    #include <pspgu.h>
    #include <pspkernel.h>
    #include <pspdisplay.h>
    #include <pspdebug.h> 
    #include <pspctrl.h>
    #include <time.h>
    #include <string.h>
    #include <pspaudiolib.h>
    #include <psprtc.h>

#endif


#include "Vector2D.h"

#define USING_MATH_TABLE

#ifdef USING_MATCH_TABLE
    #define SINF(x)     mSinTable[x]
    #define COSF(x)     mCosTable[x]
#else
    #define SINF(x)     sinf(x*DEG2RAD)
    #define COSF(x)     cosf(x*DEG2RAD)
#endif


//////////////////////////////////////////////////////////////////////////
/// A collection of core rendering functions. 
///
//////////////////////////////////////////////////////////////////////////
class JRenderer
{
protected:

    JRenderer();
    ~JRenderer();
    void InitRenderer();
    void DestroyRenderer();



public:

    //////////////////////////////////////////////////////////////////////////
    /// Get the singleton instance
    ///
    //////////////////////////////////////////////////////////////////////////
    static JRenderer* GetInstance();

    static void Destroy();

    static void Set3DFlag(bool flag);

    void BeginScene();
    void EndScene();

    //////////////////////////////////////////////////////////////////////////
    /// Render a textured quad with rotation and scaling.
    ///
    /// @param quad - Quad with texturing info.
    /// @param xo - x position.
    /// @param yo - y position.
    /// @param angle - Rotation (radian).
    /// @param xScale - Horizontal rendering scale.
    /// @param yScale - Vertical rendering scale.
    ///
    //////////////////////////////////////////////////////////////////////////
    void RenderQuad(JQuad* quad, float xo, float yo, float angle=0.0f, float xScale=1.0f, float yScale=1.0f);


    //////////////////////////////////////////////////////////////////////////
    /// Render a textured quad with new texture mapping information.
    ///
    /// @param quad - Quad with texturing information.
    /// @param points - Array of vertices with new texture mapping information.
    ///
    //////////////////////////////////////////////////////////////////////////
    void RenderQuad(JQuad* quad, VertexColor* points);

    //////////////////////////////////////////////////////////////////////////
    /// Taking a screen shot.
    /// 
    /// @note This function works on PSP only. A PNG file will be saved in 
    /// the current folder of the game applicaton.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void ScreenShot(const char* filename);

    //////////////////////////////////////////////////////////////////////////
    /// Load a texture from file.
    /// 
    /// @param filename - Name of file.
    /// @param mode - Choose to put texture in VRAM (PSP only).
    /// 
    //////////////////////////////////////////////////////////////////////////
    JTexture* LoadTexture(const char* filename, int mode = 0);

    //////////////////////////////////////////////////////////////////////////
    /// Create texture from memory on the fly.
    /// 
    /// @param width - Width of texture.
    /// @param height - Height of texture.
    /// @param mode - Choose to put texture in VRAM (PSP only)
    /// 
    //////////////////////////////////////////////////////////////////////////
    JTexture* CreateTexture(int width, int height, int mode = 0);

    //////////////////////////////////////////////////////////////////////////
    /// Clear entire screen to a particular color.
    /// 
    /// @param color - Color to fill the screen.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void ClearScreen(PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Enable VSync for the smoothness of moving objects. (PSP only)
    /// 
    /// @param flag - true to enable, false to disable.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void EnableVSync(bool flag);

    //////////////////////////////////////////////////////////////////////////
    /// Enable bi-linear filtering for better looking on-screen images.
    /// 
    /// @param flag - true to enable, false to disable.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void EnableTextureFilter(bool flag);

    //////////////////////////////////////////////////////////////////////////
    /// Remove all textures from VRAM (PSP only)
    /// 
    //////////////////////////////////////////////////////////////////////////
    void ResetPrivateVRAM();

    //////////////////////////////////////////////////////////////////////////
    /// Enable/disable swizzle optimization. (PSP only)
    /// 
    /// @param s - 1 to enable, 0 to disable.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void SetSwizzle(int s) { mSwizzle = s; }

    //////////////////////////////////////////////////////////////////////////
    /// Bind texture to be used for the rendering followed.
    /// 
    /// @param tex - Texture to use.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void BindTexture(JTexture *tex);

    //////////////////////////////////////////////////////////////////////////
    /// Set texture blending options.
    /// 
    /// @par Blending options:
    ///
    /// @code
    ///
    ///     BLEND_ZERO
    ///     BLEND_ONE
    ///     BLEND_SRC_COLOR
    ///     BLEND_ONE_MINUS_SRC_COLOR
    ///     BLEND_SRC_ALPHA
    ///     BLEND_ONE_MINUS_SRC_ALPHA
    ///     BLEND_DST_ALPHA 
    ///     BLEND_ONE_MINUS_DST_ALPHA
    ///     BLEND_DST_COLOR 
    ///     BLEND_ONE_MINUS_DST_COLOR
    ///     BLEND_SRC_ALPHA_SATURATE
    ///
    /// @endcode
    ///
    /// @param src - Blending option for source image.
    /// @param dest - Blending option for destination image.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void SetTexBlend(int src, int dest);

    //////////////////////////////////////////////////////////////////////////
    /// Set texture blending option for source image.
    /// 
    /// @param src - Blending option for source image.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void SetTexBlendSrc(int src);

    //////////////////////////////////////////////////////////////////////////
    /// Set texture blending option for destination image.
    /// 
    /// @param dest - Blending option for destination image.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void SetTexBlendDest(int dest);

    //////////////////////////////////////////////////////////////////////////
    /// Enable rendering in 2D mode.
    /// 
    /// @note To be implemented.
    ///
    //////////////////////////////////////////////////////////////////////////
    void Enable2D();


    //////////////////////////////////////////////////////////////////////////
    /// Enable rendering in 3D mode.
    ///
    /// @note To be implemented.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void Enable3D();

    //////////////////////////////////////////////////////////////////////////
    /// Restrict all rendering to a rectangular area.
    ///
    /// @note This is just the glScissor() function of OpenGL.
    /// 
    /// @param x - Left of the clipping area.
    /// @param y - Top of the clipping area.
    /// @param width - Width of the clipping area.
    /// @param height - Height of the clipping area.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void SetClip(int x, int y, int width, int height);

    //////////////////////////////////////////////////////////////////////////
    /// Reset Modelview Identity.
    ///
    //////////////////////////////////////////////////////////////////////////
    void LoadIdentity();

    //////////////////////////////////////////////////////////////////////////
    /// Tranlate position in 3D space.
    ///
    /// @param x - X position.
    /// @param y - Y position.
    /// @param z - Z position.
    ///
    //////////////////////////////////////////////////////////////////////////
    void Translate(float x, float y, float z);

    //////////////////////////////////////////////////////////////////////////
    /// Rotate along X axis.
    /// 
    /// @param angle - Angle to rotate ( in radians).
    /// 
    //////////////////////////////////////////////////////////////////////////
    void RotateX(float angle);

    //////////////////////////////////////////////////////////////////////////
    /// Rotate along Y axis.
    /// 
    /// @param angle - Angle to rotate ( in radians).
    /// 
    //////////////////////////////////////////////////////////////////////////
    void RotateY(float angle);

    //////////////////////////////////////////////////////////////////////////
    /// Rotate along Z axis.
    /// 
    /// @param angle - Angle to rotate ( in radians).
    /// 
    //////////////////////////////////////////////////////////////////////////
    void RotateZ(float angle);

    //////////////////////////////////////////////////////////////////////////
    /// Push matrix.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void PushMatrix();

    //////////////////////////////////////////////////////////////////////////
    /// Pop matrix.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void PopMatrix();

    //////////////////////////////////////////////////////////////////////////
    /// Set the field of view angle (in degrees), effective at the next
    /// Enable3D() call.
    /// 
    /// @param fov - The field of view angle (in degrees).
    /// 
    //////////////////////////////////////////////////////////////////////////
    void SetFOV(float fov);

    //////////////////////////////////////////////////////////////////////////
    /// Render triangles.
    /// 
    /// @param texture - Texture for the triangles.
    /// @param tris - List of triangles.
    /// @param start - starting index (Note: Index of triangles, NOT vertices).
    /// @param count - Number of triangles (Note: NOT number of vertices).
    ///
    //////////////////////////////////////////////////////////////////////////
    void RenderTriangles(JTexture* texture, Vertex3D *tris, int start, int count);

    //////////////////////////////////////////////////////////////////////////
    /// Fill a rectangular area with a specified color.
    ///
    /// @param x - Starting x position.
    /// @param y - Starting y position.
    /// @param width - Width of the rectangle.
    /// @param height - Height of the rectangle.
    /// @param color - Filling color.
    ///
    //////////////////////////////////////////////////////////////////////////
    void FillRect(float x, float y, float width, float height, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Fill a rectangular area with a single color for each vertex.
    ///
    /// @param x - Starting x position.
    /// @param y - Starting y position.
    /// @param width - Width of the rectangle.
    /// @param height - Height of the rectangle.
    /// @param color - Array of colors.
    ///
    //////////////////////////////////////////////////////////////////////////
    void FillRect(float x, float y, float width, float height, JColor* color);
    void FillRect(float x, float y, float width, float height, PIXEL_TYPE* color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw a rectangle.
    ///
    /// @param x - Starting x position.
    /// @param y - Starting y position.
    /// @param width - Width of the rectangle.
    /// @param height - Height of the rectangle.
    /// @param color - Filling color.
    ///
    //////////////////////////////////////////////////////////////////////////
    void DrawRect(float x, float y, float width, float height, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw a single line.
    ///
    /// @param x1 - Starting vertex, x.
    /// @param y1 - Starting vertex, y.
    /// @param x2 - Ending vertex, x.
    /// @param y2 - Ending vertex, y.
    /// @param color - Filling color.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void DrawLine(float x1, float y1, float x2, float y2, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw thick line.
    ///
    /// @param x1 - Starting vertex, x.
    /// @param y1 - Starting vertex, y.
    /// @param x2 - Ending vertex, x.
    /// @param y2 - Ending vertex, y.
    /// @param lineWidth - Line width.
    /// @param color - Filling color.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void DrawLine(float x1, float y1, float x2, float y2, float lineWidth, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Plot a pixel on screen.
    /// 
    /// @param x - X position of the pixel.
    /// @param y - Y position of the pixel.
    /// @param color - Draw colour.
    /// 
    //////////////////////////////////////////////////////////////////////////
    void Plot(float x, float y, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Plot an array of pixels.
    /// 
    /// @param x - Array of X positions.
    /// @param y - Array of Y positions.
    /// @param count - Number of pixels to plot.
    /// @param color - Color of pixel.
    ///
    //////////////////////////////////////////////////////////////////////////
    void PlotArray(float *x, float *y, int count, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw polygon with filled colour.
    /// 
    /// @param x - Array of X positions.
    /// @param y - Array of Y positions.
    /// @param count - Side count of the polygon.
    /// @param color - Filling colour.
    ///
    //////////////////////////////////////////////////////////////////////////
    void FillPolygon(float* x, float* y, int count, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw polygon.
    /// 
    /// @param x - Array of X positions.
    /// @param y - Array of Y positions.
    /// @param count - Side count of the polygon.
    /// @param color - Draw colour.
    ///
    //////////////////////////////////////////////////////////////////////////
    void DrawPolygon(float* x, float* y, int count, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw symmetric polygon with certain number of sides.
    /// 
    /// @param x - X positions of center of the polygon.
    /// @param y - Y positions of center of the polygon.
    /// @param size - Size of polygon.
    /// @param count - Side count of the polygon.
    /// @param startingAngle - Rotation angle of the polygon.
    /// @param color - Draw colour.
    ///
    //////////////////////////////////////////////////////////////////////////
    void DrawPolygon(float x, float y, float size, int count, float startingAngle, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw solid symmetric polygon with certain number of sides.
    /// 
    /// @param x - X positions of center of the polygon.
    /// @param y - Y positions of center of the polygon.
    /// @param size - Size of polygon.
    /// @param count - Side count of the polygon.
    /// @param startingAngle - Rotation angle of the polygon.
    /// @param color - Filling colour.
    ///
    //////////////////////////////////////////////////////////////////////////
    void FillPolygon(float x, float y, float size, int count, float startingAngle, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw circle with filled colour.
    /// 
    /// @param x - X positions of center of the circle.
    /// @param y - Y positions of center of the circle.
    /// @param radius - Radius of circle.
    /// @param color - Filling colour.
    ///
    //////////////////////////////////////////////////////////////////////////
    void FillCircle(float x, float y, float radius, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw circle.
    /// 
    /// @param x - X positions of center of the circle.
    /// @param y - Y positions of center of the circle.
    /// @param radius - Radius of circle.
    /// @param color - Draw colour.
    ///
    //////////////////////////////////////////////////////////////////////////
    void DrawCircle(float x, float y, float radius, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw a rectangle with round corners.
    ///
    /// @param x - Starting x position.
    /// @param y - Starting y position.
    /// @param w - Width of the rectangle.
    /// @param h - Height of the rectangle.
    /// @param radius - Radius of the round corners.
    /// @param color - Drawing color.
    ///
    //////////////////////////////////////////////////////////////////////////
    void DrawRoundRect(float x, float y, float w, float h, float radius, PIXEL_TYPE color);

    //////////////////////////////////////////////////////////////////////////
    /// Draw filled rectangle with round corners.
    ///
    /// @param x - Starting x position.
    /// @param y - Starting y position.
    /// @param w - Width of the rectangle.
    /// @param h - Height of the rectangle.
    /// @param radius - Radius of the round corners.
    /// @param color - Filling color.
    ///
    //////////////////////////////////////////////////////////////////////////
    void FillRoundRect(float x, float y, float w, float h, float radius, PIXEL_TYPE color);


    //////////////////////////////////////////////////////////////////////////
    /// Set custom image filter to be used at texture loading.
    ///
    /// @param imageFilter - Custom image filter.
    ///
    //////////////////////////////////////////////////////////////////////////
    void SetImageFilter(JImageFilter* imageFilter);

private:

    struct TextureInfo
    {
        u8 *mBits;
        int mWidth;
        int mHeight;
        int mTexWidth;
        int mTexHeight;
        bool mVRAM;
    };

    void LoadJPG(TextureInfo &textureInfo, const char *filename, int mode = 0);
    void LoadPNG(TextureInfo &textureInfo, const char *filename, int mode = 0);
    void LoadGIF(TextureInfo &textureInfo, const char *filename, int mode = 0);
    int image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode = 0);

    static JRenderer* mInstance;


#ifdef WIN32

    GLuint mCurrentTex;


#else

    u32 mVideoBufferStart;
    //u32 mCurrentPointer;
    PIXEL_TYPE* mVRAM;
    int mCurrentTex;
    int mCurrentBlend;

#endif

    bool mVsync;

    int mSwizzle;
    int mTexCounter;

    //int mTexFilter;

    int mCurrentTextureFilter;

    int mCurrTexBlendSrc;
    int mCurrTexBlendDest;

    JImageFilter* mImageFilter;

    int mCurrentRenderMode;

    float mFOV;

#ifdef USING_MATH_TABLE
    float mSinTable[360];
    float mCosTable[360];
#endif

    static bool m3DEnabled;
};


#endif

попытался откомпилировать minimal.cpp с помощью GCC 4.8.2, не вышло:

C:>g++ -std=c++11 -D_UNICODE -DUNICODE -IM:sciterinclude minimal.cpp
In file included from M:sciterinclude/value.hpp:26:0,
                 from M:sciterinclude/value.h:293,
                 from M:sciterinclude/sciter-x-def.h:24,
                 from M:sciterinclude/sciter-x.h:5,
                 from minimal.cpp:5:
M:sciterinclude/aux-cvt.h: In constructor 'aux::itot<CT>::itot(int, int)':
M:sciterinclude/aux-cvt.h:685:7: error: 'reverse' is not a member of 'std'
       std::reverse(buffer,wstr);
       ^
In file included from M:sciterinclude/sciter-x.h:4:0,
                 from minimal.cpp:5:
M:sciterinclude/sciter-x-dom.h: At global scope:
M:sciterinclude/sciter-x-types.h:163:27: error: expected unqualified-id before string constant
   #define EXTERN_C extern "C"
                           ^
M:sciterinclude/sciter-x-dom.h:171:10: note: in expansion of macro 'EXTERN_C'
 OBSOLETE EXTERN_C SCDOM_RESULT SCAPI SciterGetElementHtml(HELEMENT he, LPCBYTE* utf8bytes, BOOL outer);
          ^
M:sciterinclude/sciter-x-types.h:163:27: error: expected unqualified-id before string constant
   #define EXTERN_C extern "C"
                           ^
M:sciterinclude/sciter-x-dom.h:191:11: note: in expansion of macro 'EXTERN_C'
  OBSOLETE EXTERN_C SCDOM_RESULT SCAPI SciterGetElementText(HELEMENT he, LPWSTR* utf16);
           ^
In file included from M:sciterinclude/sciter-x.h:14:0,
                 from minimal.cpp:5:
M:sciterinclude/sciter-x-host-callback.h: In function 'bool sciter::load_resource_data(HINSTANCE, LPCWSTR, const BYTE*&, UINT&)':
M:sciterinclude/sciter-x-host-callback.h:228:60: error: invalid conversion from 'LPCWSTR {aka const wchar_t*}' to 'size_t {aka unsigned int}' [-fpermissive]
     WCHAR achURL[MAX_PATH]; wcsncpy_s(achURL, uri, MAX_PATH);
                                                            ^
M:sciterinclude/sciter-x-host-callback.h:228:60: error: invalid conversion from 'int' to 'const wchar_t*' [-fpermissive]
M:sciterinclude/sciter-x-host-callback.h:228:60: error: too few arguments to function 'errno_t wcsncpy_s(wchar_t*, size_t, const wchar_t*, size_t)'
In file included from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/string.h:176:0,
                 from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/guiddef.h:148,
                 from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/winnt.h:602,
                 from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/minwindef.h:146,
                 from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/windef.h:8,
                 from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/windows.h:69,
                 from minimal.cpp:4:
C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/sec_api/string_s.h:53:27: note: declared here
   _CRTIMP errno_t __cdecl wcsncpy_s(wchar_t *_Dst,size_t _DstSizeInChars,const wchar_t *_Src,size_t _MaxCount);
                           ^
In file included from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/excpt.h:9:0,
                 from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/windows.h:65,
                 from minimal.cpp:4:
C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/sec_api/stdio_s.h: In instantiation of 'int sprintf_s(char (&)[__size], const char*, ...) [with unsigned int __size = 512u]':
M:sciterinclude/tiscript.hpp:363:86:   required from here
C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/sec_api/stdio_s.h:30:3: error: 'vsprintf_s' was not declared in this scope, and no declarations were found by argument-dependent lookup at
 the point of instantiation [-fpermissive]
   __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1_ARGLIST(int,sprintf_s,vsprintf_s,char,_DstBuf,const char*,_Format)
   ^
In file included from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/excpt.h:9:0,
                 from C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/windows.h:65,
                 from minimal.cpp:4:
C:/Base/Compiler/MinGW-4.8.2/i686-w64-mingw32/include/sec_api/stdio_s.h:48:3: note: 'template<unsigned int __size> int vsprintf_s(char (&)[__size], const char*, va_list)' declared here, later in the translation unit
   __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(int, vsprintf_s, char, _DstBuf, const char*, _Format, va_list, _ArgList)
   ^

Здравствуйте, BulatZiganshin, Вы писали:

BZ>попытался откомпилировать minimal.cpp с помощью GCC 4.8.2, не вышло:

А что это за GCC в котором нет std::reverse ?

И кто бы мне обяснил что конкретно ему не нравится здесь:

#define EXTERN_C extern "C"

Здравствуйте, c-smile, Вы писали:

CS>А что это за GCC в котором нет std::reverse ?

std::reverse определён в algorithm, который через sciter-x.h включается позже. тут скорее должна претензия к msvc, который подключает его непонятно откуда

CS>И кто бы мне обяснил что конкретно ему не нравится здесь:

CS>#define EXTERN_C extern «C»

это попытка gcc найти причину ошибки. сама же ошибка в следующем сообщении — вместо OBSOLETE EXTERN_C для gcc надо писать в обратном порядке — EXTERN_C OBSOLETE. как вариант, можете сделать extern «C» {…} вокруг групп определений

Здравствуйте, BulatZiganshin, Вы писали:

BZ>Здравствуйте, c-smile, Вы писали:


CS>>А что это за GCC в котором нет std::reverse ?


BZ>std::reverse определён в algorithm, который через sciter-x.h включается позже. тут скорее должна претензия к msvc, который подключает его непонятно откуда

Ну как бы этот же код он и clang’ом компилируется…

Причесывать SDK headers под GCC мне еще предстоит.

Home » U++ Library support » U++ Core » A Very Strange Issue (U++ Core Bug (?))

icon1.gif  A Very Strange Issue [message #43769] Wed, 08 October 2014 03:01 Go to next message
Omnipraesens is currently offline 
Omnipraesens

Messages: 5
Registered: October 2014

Promising Member

I have been experiencing a very strange error when working on some code… Every time I compile, I get this error. The particularly strange part is that without updating or editing the U++ header files, this error appeared. The previous evening, my compiles had not been failing. Anyone have a clue why this might be?

/home/CENSORED/upp/uppsrc/Core/Defs.h:424:8: error: expected unqualified-id before string constant
extern «C» byte *i;
^

NOTE: The specific code I am working on is both non-trivial and proprietary, so unfortunately while I would love to share it I cannot. I am willing to attempt to make a compilable test program, but I would like to ask before doing that just in case the solution is trivial, obvious, or the cause is already known from previous investigation.

Thanks in advance for your consideration, and the time spent reading this message.

Re: A Very Strange Issue [message #43770 is a reply to message #43769] Wed, 08 October 2014 10:33 Go to previous messageGo to next message
Hi Omnipraesens,

Welcome to the forum Cool

Omnipraesens wrote on Wed, 08 October 2014 03:01

Anyone have a clue why this might be?

/home/CENSORED/upp/uppsrc/Core/Defs.h:424:8: error: expected unqualified-id before string constant
extern «C» byte *i;

Hard to say without seeing the code, but my wild guess would be missing semicolon or similar syntactic error somewhere in your code, just before you use BINARY macro. By the way, what compiler are you using?

Best regards,
Honza

Re: A Very Strange Issue [message #43774 is a reply to message #43770] Wed, 08 October 2014 23:52 Go to previous messageGo to next message
Didier is currently offline 
Didier

Messages: 675
Registered: November 2008
Location: France

Contributor

Hello Omnipraesens,

I already had the same type of issue : for me it was some bad character (that was invisible but present) that lead to the error.
I got this error by doing some copy/paste from another editor/visualiser (I don’t remember which one, it was quite long ago)

Re: A Very Strange Issue [message #43784 is a reply to message #43769] Sat, 11 October 2014 19:42 Go to previous message
Omnipraesens is currently offline 
Omnipraesens

Messages: 5
Registered: October 2014

Promising Member

Thanks for the responses; I found the problem, actually…
Forgot a semicolon after defining a class I had been working on. Embarassed
I make the most anticlimactic mistakes sometimes.

And BTW, I am using GCC 4.9.1-2 from the Arch repositories.

[Updated on: Sat, 11 October 2014 22:19]

Report message to a moderator

Goto Forum:

  

Current Time: Thu Feb 09 14:36:52 CET 2023

Total time taken to generate the page: 0.01821 seconds

Понравилась статья? Поделить с друзьями:
  • Error expected unqualified id before return
  • Error expected unqualified id before public
  • Error expected unqualified id before numeric constant перевод
  • Error expected unqualified id before numeric constant ошибка
  • Error expected unqualified id before int