在使用MinGW进行编译时,我必须在运行exe之前从MinGW bin目录复制某些dll文件(即使使用"-static"和/或"-static-libstdc ++").如何更改?我必须使用MinGW的特殊版本吗?最终我希望能够在目录中运行除了exe之外的程序(并且没有设置windows环境变量).这些文件是:
以下是我休闲的完整步骤列表:
查看邮件
Hello World!
Run Code Online (Sandbox Code Playgroud)编辑: 我的命令行是:
g++.exe -Wall -fexceptions -static -static-libgcc -static-libstdc++ -g -static-libgcc -static-libstdc++ -L. -c "C:\Users\______\Desktop\Hello World\main.cpp" -o obj\Debug\main.o
g++.exe -o "bin\Debug\Hello World.exe" obj\Debug\main.o
Run Code Online (Sandbox Code Playgroud)
需要上面提到的所有dll文件.并且,为了安全起见,代码是:
// …Run Code Online (Sandbox Code Playgroud) 到目前为止,在MinGW中,'$'似乎只是一个基本字符(如'a'),可用于名称(变量,函数等)但它看起来不像一个.是否有一些隐藏的功能使用'$'作为我失踪的名字的一部分?
int $m = 2;
printf("$m = %i", $m);
Run Code Online (Sandbox Code Playgroud)
控制台输出:
$m = 2
Run Code Online (Sandbox Code Playgroud)
但是,当用作字符时,"@"符号会产生错误.error: stray '@' in program我认为它意味着它用于什么?维基百科和MSDN都没有提到任何一个角色.Google为"符号"或"C"提供了大量匹配.
我将错误范围缩小到了OpenGL调用:
glVertexAttribPointer(var.vertex, 4, GL_FLOAT, GL_FALSE, 0, 0);
Run Code Online (Sandbox Code Playgroud)
之前没有错误,之后也有GL_INVALID_OPERATION错误。输出到我的控制台是:
Error in Shader.cpp : bindMesh : 294
OpenGL Error: Invalid Operation
(0x502)
Bound Buffer: 1
var.vertex = 1
Run Code Online (Sandbox Code Playgroud)
据此,唯一适用的GL_INVALID_OPERATION条件是绑定缓冲区ID为0。但是绑定缓冲区ID为1。
我正在检查(并打印)以下错误:
printErrors();
int i = 0;
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &i);
printf("\tBound Buffer: %i\n", i);
printf("\tvar.vertex = %i\n", var.vertex);
Run Code Online (Sandbox Code Playgroud)
在哪里printErrors()定义为
void PrintErrors(const char* file, const char* func, int line);
#define printErrors() PrintErrors(__BASE_FILE__,__func__,__LINE__)
void PrintErrors(const char* file, const char* func, int line)
{
const char* errors[] = {
"OpenGL Error: Invalid Enumeration\n", …Run Code Online (Sandbox Code Playgroud) 比方说我有:
char name[16] = "123456789abc";
Run Code Online (Sandbox Code Playgroud)
所以name[11] == 'c',name[12] == '\0'.
将name[13]是乱码/编译器依赖,还是可靠地是特定值(例如'\ 0'?)
这个一般概念会被视为"坏"吗?使用函数typedef预先计算哪个函数的优化处理存储的数据的概念?或者我应该坚持if和切换语句以防止其他程序员畏缩?除了把这个名字中的名字放在一起的例子:
#ifndef __PROJECT_CIMAGE_H_
#define __PROJECT_CIMAGE_H_
#define FORMAT_RGB 0
#define FORMAT_BGR 1
typedef unsigned char ImageFormat;
class CImage
{
protected:
// image data
Components* data;
ImageFormat format;
// typedef the functions
typedef void(*lpfnDeleteRedComponentProc)();
typedef void(*lpfnDeleteGreenComponentProc)();
typedef void(*lpfnDeleteBlueComponentProc)();
// specify the different functions for each supported format
void DeleteRedComponentRGB();
void DeleteGreenComponentRGB();
void DeleteBlueComponentRGB();
void DeleteRedComponentBGR();
void DeleteGreenComponentBGR();
void DeleteBlueComponentBGR();
// Add in references to which functions to use.
lpfnDeleteRedComponentProc DRC;
lpfnDeleteGreenComponentProc DGC;
lpfnDeleteBlueComponentProc DBC;
public:
Image(); // Allocate some basic data
~Image(); …Run Code Online (Sandbox Code Playgroud)