【问题标题】:Error while running in different Operating System在不同的操作系统中运行时出错
【发布时间】:2017-03-06 02:11:49
【问题描述】:

我收到以下错误。我自己无法解决。

错误信息:

interface.cpp:191:10: error: request for member 'FaceSize' in 'interface::font', which is of non-class type 'void*'
 font.FaceSize(fontSize);
      ^
interface.cpp:202:18: error: request for member 'Render' in 'interface::font', which is of non-class type 'void*'
 font.Render(todisplay);
      ^
interface.cpp:215:10: error: request for member 'Render' in 'interface::font', which is of non-class type 'void*'
 font.Render(todisplay);
      ^

以下是错误出处的代码sn-p:

#if defined(__APPLE__)
FTGLPixmapFont font("/Library/Fonts/Arial.ttf");
#elif defined(_WIN32) || defined(_WIN64) || defined(WINDOWS) || defined(MINGW) || defined(MINGW64)
FTGLPixmapFont font("C:\\Windows\\Fonts\\Arial.ttf");
#elif defined(__LINUX__)
FTGLPixmapFont 
font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf");
#endif

font.FaceSize(fontSize);
glPushMatrix();
for (float xCount = -borderWidth/2; xCount <= borderWidth/2; xCount++)
{
    for (float yCount = -borderWidth/2; yCount <= borderWidth/2; yCount++)
    {
        glRasterPos3f(
            x+xCount*fontscaleX,
            y+yCount*fontscaleY,
            INTERFACE_TEXT_SHADER_DEPTH
        );

        font.Render(todisplay);
    }
}

glColor3f(foregroundRed, foregroundGreen, foregroundBlue);

glRasterPos3f(x, y, INTERFACE_TEXT_DEPTH);
font.Render(todisplay);
glPopMatrix();

此代码在 OS X 中完美构建,没有任何问题。但是当我尝试在 ubuntu 中构建时,它无法构建。我正在尝试使用图标脚本进行构建。下面是编译interface.cpp文件的命令:

g++ -o interface.o -c -Wall -ansi -pedantic -O2 -lGL -lGLU -lX11 -std=c++11 -DSETTINGS_DEVELOPMENT -DUSER_UMA -I/usr/include/mysql -I/opt/local /include -I/usr/include/boost/system -I/usr/include/boost -I/usr/include/boost/test -I/usr/include/boost/timer -I/opt/local/include/mariadb /mysql -I/usr/include/freetype2 -Irapidxml -Ilru_cache interface.cpp

【问题讨论】:

  • 认为它应该是__linux__,而且由于__LINUX__ 没有被定义,你正在选择一个font 类型的全局void*从某处。我会在里面贴上#else error "Unsupported platform" 以确保。
  • 嗨 molbdnilo 感谢您的回复。不,我也尝试了两个 linux,但它确实有效。它现在适用于 unix。但我不知道为什么

标签: c++ ubuntu fonts g++ ftgl


【解决方案1】:

在你的情况下,预处理器可能没有定义__linux__

根据GCC Manualthis answer,您可以通过运行检查哪些宏是预定义的:

$ touch dummy.cpp
$ cpp -dM dummy.cpp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    相关资源
    最近更新 更多