Van*_*nel 0 c++ compiler-errors
我正在使用Android NDK r6b编译共享库.所有类都是C++.
我有以下两个类:
Utils.hpp
#ifdef USE_OPENGL_ES_1_1
#include <GLES/gl.h>
#include <GLES/glext.h>
#else
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#endif
#include <android/log.h>
// Utility for logging:
#define LOG_TAG "ROTATEACCEL"
#define LOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#ifdef __cplusplus
extern "C" {
#endif
static void checkGlError(const char* op);
#ifdef __cplusplus
}
#endif
Run Code Online (Sandbox Code Playgroud)
Utils.cpp
#include "Utils.hpp"
#ifdef __cplusplus
extern "C" {
#endif
static void checkGlError(const char* op) {
for (GLint error = glGetError(); error; error
= glGetError()) {
LOGI("after %s() glError (0x%x)\n", op, error);
}
}
#ifdef __cplusplus
}
#endif
Run Code Online (Sandbox Code Playgroud)
当我想在其他C++文件中使用此函数时#include "Utils.hpp".但是,在这些文件中我收到一个错误:
undefined reference to `checkGlError'
Run Code Online (Sandbox Code Playgroud)
为什么我收到这个警告?
你做到了static.因此,它只存在于特定的翻译单元中.解决方案是删除static关键字.
警告告诉您,在"承诺"的头文件中,如果需要一个,那么在该翻译统一中将有一个定义,但是没有提供一个并且需要它.
| 归档时间: |
|
| 查看次数: |
2866 次 |
| 最近记录: |