我的问题很简单:假设有一个xcode项目a.xcodeproj,我可以用命令打开它xcode a.xcodeproj吗?
如果我尝试这个,我收到以下错误消息:
-bash: xcode: command not found
Run Code Online (Sandbox Code Playgroud) 此页面包含CMake已为我们定义的变量的完整摘要.我觉得有些变数是一样的.采取的例子CMAKE_SOURCE_DIR和PROJECT_SOURCE_DIR为例.它们是相同的,指的是定义顶级CMakeLists.txt的文件夹.所以我的问题是:它们之间有细微差别吗?谢谢.
使用以下cmake scrpt:
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
Run Code Online (Sandbox Code Playgroud)
我们可以打印CMake项目中的所有变量.然后我的问题是:是否有一个可以打印目标的所有属性的函数?
我是CMake的新手,我想知道LINUX环境中的C++/C项目如何让CMake可以选择gcc和g ++之间的编译器.更具体地说,我的问题如下:
我将使用以下示例来说明我的问题:
template<typename T>
T diff(T a, T b)
{
return a-b;
}
Run Code Online (Sandbox Code Playgroud)
我希望这个模板功能只有在签名类型T时才有效.我能想到的唯一解决方案是对所有无符号类型使用delete关键字:
template<>
unsigned char diff(unsigned char,unsigned char) == delete;
template<>
unsigned char diff(unsigned char,unsigned char) == delete;
Run Code Online (Sandbox Code Playgroud)
还有其他解决方案吗?
在dll-interface中使用stl-classes作为处理警告c4251的常用做法不是一个好习惯:class ...需要有dll-interface解释.给出了一个例子:
#include <iostream>
#include <string>
#include <vector>
class __declspec(dllexport) HelloWorld
{
public:
HelloWorld()
{
abc.resize(5);
for(int i=0; i<5; i++)
abc[i] = i*10;
str="hello the world";
}
~HelloWorld()
{
}
std::vector<int> abc;
std::string str;
};
Run Code Online (Sandbox Code Playgroud)
编译此文件时,可以观察到以下警告:
warning C4251: 'HelloWorld::str' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'HelloWorld'
warning C4251: 'HelloWorld::abc' : class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'HelloWorld'
Run Code Online (Sandbox Code Playgroud)
那么问题是我们如何在不使用STL类向量和字符串的情况下实现相同的功能.我能想到的一个实现如下:
class __declspec(dllexport) HelloWorld2 …Run Code Online (Sandbox Code Playgroud) 我明白,当我们定义类的类复制构造函数时,必须作为三个状态的规则.我还注意到复制构造函数的参数通常const如下面的代码所示:
class ABC {
public:
int a;
int b;
ABC(const ABC &other)
{
a = other.a;
b = other.b;
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如果复制构造函数的参数不是const会发生什么:
class ABC
{
public:
int a;
int b;
ABC(ABC &other)
{
a = other.a;
b = other.b;
}
}
Run Code Online (Sandbox Code Playgroud)
我理解在某些情况下,如果复制构造函数的参数是const,那么第二个实现将失败.此外,如果复制构造函数的参数是const,则要复制的对象在此过程中不会更改其内容.但是,我注意到有些人仍然使用第二个实现而不是第一个实现.是否有任何理由认为第二种实施方式是首选的?
我现在使用Microsoft Visual Studio 2010 Performance Profiler来配置一个程序.当我使用CPU采样方法时,它工作得很好.但是,当我使用Instrumentation方法时,我收到以下错误消息:
PRF0002: Instrumentation failed with these options: /u "my program" /excludesmallfuns. Please check the output window for additional details.
Run Code Online (Sandbox Code Playgroud)
我想知道如何摆脱这个错误.谢谢!
如何在不同的CMake文件之间共享变量,并显示以下示例来说明我的问题:
cmake_minimum_required(VERSION 2.6)
project(test)
set(Var3 "Global variable")
add_subdirectory(${test_SOURCE_DIR}/exe)
add_subdirectory(${test_SOURCE_DIR}/dll)
Run Code Online (Sandbox Code Playgroud)
set(Var1 "this is variable 1")
set(Var1 ${Var1} " added to varible 1")
message(STATUS ${Var1})
Run Code Online (Sandbox Code Playgroud)
set(Var2 "this is variable 2")
message(STATUS ${Var2})
message(STATUS ${Var1})
message(STATUS ${Var3})
Run Code Online (Sandbox Code Playgroud)
在这个例子中,VAR3可以的CMake的文件中可以看出exe,并dll因为它是在定义Main.但是,exe将不会在其中定义Var1 dll.我只是很好奇:有没有办法让var1在exeobservable中定义dll?
当我们使用Visual Studio运行C++程序时,Configuration Properties->Debugging如果程序需要一些参数,我们经常会在内部设置"Command Arguments" .例如,我们可以abc.exe -r 1在命令行中运行,并且为了直接在Visual Studio中运行程序,我们可以用命令填充命令参数 -r 1.所以我的问题是:我们可以用cmake设置默认的命令参数吗?通过这样做,不需要手动设置它们.谢谢.