如何使用Cake构建系统,现在使用AUX_SOURCE_DIRECTORY扫描源文件,在同一目录中扫描头文件,最好使用类似的命令?
我还没有在文档中找到一种简单的方法,所以我现在有一个糟糕的bash脚本来后处理我的(CodeBlocks)项目文件......
通常我使用视觉工作室,但我切换到mingw,我喜欢使我的应用程序可以从unicode和多字节轻松更改,在我的mingw项目中我有我的定义,包括这样:
#define WIN32_LEAN_AND_MEAN
#define WINVER 0x0700
#define _UNICODE
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#define WND_MAIN_CLASS _T("MainWindowFrame")
Run Code Online (Sandbox Code Playgroud)
然后我注册并创建我的窗口,例如
WNDCLASSEX wc;
...
wc.lpszClassName = WND_MAIN_CLASS;
RegisterClassEx(&wc);
hwnd = CreateWindowEx(0, WND_MAIN_CLASS, _T("Main Window"),
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInst, NULL);
Run Code Online (Sandbox Code Playgroud)
但是当我去编译时,我得到错误,它无法将Wchar_t转换为WNDCLASSEX上的CHAR*和类名称和窗口标题上的CreateWindowEx上的CHAR*.
如果我右键单击并转到createwindowex和WNDCLASSEX的声明,它会从winuser.h中得到这些:
typedef WNDCLASSEXW WNDCLASSEX,*LPWNDCLASSEX,*PWNDCLASSEX;
#define CreateWindowEx CreateWindowExW
Run Code Online (Sandbox Code Playgroud)
如果我注释掉定义_UNICODE它编译并且没有任何问题
#include <stdlib.h>
#include <mysql.h>
#include <my_global.h>
int main (int argc, char *argv[])
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "127.0.0.1";
char *user = "root";
char *password = "1386";
char *database = "OurDB";
conn = mysql_init(NULL);
/* Connect to database */
if (!mysql_real_connect(conn, server,user, password, database, 0, NULL, 0))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(0);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我在代码块中收到链接器错误:
undefined reference to mysql_init
Run Code Online (Sandbox Code Playgroud)
我mysql_config --libs在链接器选项和mysql_config --cflags编译器选项中使用过。
我读过某个地方,我应该添加一些库,例如libmysql.lib,但我在PC上找不到此文件(我使用的是Ubuntu 11.04 64bit)。
我需要unique_ptr在我的C++任务中使用.
我下载了一个新的编译器TDM-GCC-4.7.1并安装了它.然后我将GNU GCC Compiler的目录更改为选项中的安装路径:Setting->Compiler...->Toolchain Executable.
但它不起作用.当我定义一个unique_ptr.会发生错误:"unique pointer is not a command of 'std' "
使用智能指针的原因是提供强大的异常安全性,这也是此分配的要求.我只需要使用C++ 11的这个新功能......另外,我使用的操作系统是Window 7.
谢谢!
我是Code :: Blocks的新手.对于我的学习,我正在用C语言编写几个小程序(只是为了尝试一下).我试图将它们全部放在一个项目中,因为它们属于同一个主题,但这不起作用,因为每个项目都有一个主要功能.
有什么想法我怎么能把这些文件放在一起,但不依赖于彼此?
我写了这个头文件(header1.h):
#ifndef HEADER1_H
#define HEADER1_H
class first ;
//int summ(int a , int b) ;
#endif
Run Code Online (Sandbox Code Playgroud)
和这个源文件(header1.cpp and main.cpp):
#include <iostream>
#include "header1.h"
using namespace std;
class first
{
public:
int a,b,c;
int sum(int a , int b);
};
int first::sum(int a , int b)
{
return a+b;
}
Run Code Online (Sandbox Code Playgroud)
#include <iostream>
#include "header1.h"
using namespace std;
first one;
int main()
{
int j=one.sum(2,4);
cout << j<< endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行这个程序时codeblocks,我给出了这个错误:
聚合'第一个'具有不完整的类型,无法定义.
我教授的家庭作业的代码如下.这是开箱即用的,我没有修改我教授的代码.程序还有更多内容,但这是错误发生的地方.问题行以粗体显示.
std::cout << "\nAll remaining courses with enrollments:\n";
allCourses = WSUCourse::getAllCourses();
std::for_each(
allCourses.begin(),
allCourses.end(),
WSUCoursePrinter());
Run Code Online (Sandbox Code Playgroud)
我收到以下错误.
g++ -c -g -std=c++11 -MMD -MP -MF "build/Debug/Cygwin_4.x-Windows/main.o.d" -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
main.cpp: In member function 'void WSUStudentPrinter::operator()(const WSUStudent*)':
main.cpp:26:20: error: 'to_string' is not a member of 'std'
std::cout << std::to_string(studentPtr->getUniqueID()) <<
^
main.cpp: In function 'void test()':
main.cpp:162:4: error: 'for_each' is not a member of 'std'
std::for_each(
^
main.cpp:174:4: error: 'for_each' is not a member of 'std'
std::for_each(
^
nbproject/Makefile-Debug.mk:84: recipe for target 'build/Debug/Cygwin_4.x-Windows/main.o' …Run Code Online (Sandbox Code Playgroud) 我已经使用以下命令行在Linux Mint 17.1(KDE)中安装了代码块
sudo apt-get安装代码块
,但是当我尝试在代码块上编译并运行ac程序时,它显示了此错误
/ home / redwan / Programmin / C程序/hello.c | 1 |严重错误:stdio.h:无此类文件或目录| || ===构建失败:1个错误,0个警告(0分钟,0秒)=== |
请有人帮助我使用代码块在linux mint 17.1(KDE)中正确运行c以及c ++程序。
对不起,我的英语不好。
就像标题所说,我需要code::blocks与之合作C11,我无法弄清楚如何去做.
我去了settings=> compiler settings=> Other options我添加-std=c11并尝试了-std=gnu11,两者似乎都没有用.
我编译gcc-5.2然后我更改了默认编译器(gcc-4.9)仍然没有结果.
当我尝试编译以下程序时:
#include<stdio.h>
int main(void){
int arr[] = {0,1,2,3,4};
for(int i=0;i<5;i++){
printf("%d ",arr[i]);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到以下内容:
|6|error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode|
Run Code Online (Sandbox Code Playgroud)
但如果我在终端(ubuntu 15.04,64BIT,gcc-5.2)中这样做:
./install/gcc-5.2.0/bin/gcc5.2 program.c -o program
Run Code Online (Sandbox Code Playgroud)
似乎工作正常.
我的问题是,如何code::blocks与之合作c11?
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
int main()
{
int i;
int diceRoll;
for(i=0; i < 20; i++)
{
printf("%d \n", rand());
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我在c(codeblocks)中编写的代码来获取随机数,问题是我总是得到相同的序列:41,18467,6334,26500等等...
我还在学习,所以请尝试解释,就像你正在和一个8岁的D谈话: