我有遗留代码依赖于指针,32-bit并希望xCodeBuild用来构建代码command line.由于某种原因,这不起作用.这是我使用的命令:
xcodebuild -configuration Debug -arch i386
-workspace MyProject.xcworkspace -scheme MyLib
Run Code Online (Sandbox Code Playgroud)
这是我得到的输出
[BEROR]No architectures to compile for
(ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).
Run Code Online (Sandbox Code Playgroud)
显然,它试图建立x86_64的代码,并惨遭失败,因为我只启用i386从VALID_ARCHSXcode中的项目设置.
有没有办法让它理解我不想要一个64-bit图书馆?
我想编写一个函数,它在两个参数a和b不同类型之间执行除法,a/b如果定义了除法运算符,则使用表达式,或者a * (1/b)如果没有这样的运算符则返回.
这是我的想法,但我不知道如何定义两个*和/运算符时禁用第二个定义(或优先第一个定义):
template<typename T, typename U>
auto smart_division(T a, U b) -> decltype (a/b) {
return a/b;
}
template<typename T, typename U>
auto smart_division(T a, U b) -> decltype (a * (U(1)/b)) {
return a * (U(1)/b);
}
Run Code Online (Sandbox Code Playgroud) 在xcode 3中,可以配置用于构建项目的每个单个文件的特定选项,例如禁用特定警告,拇指代码生成等.
在xcode 4中,这种功能不可用,或者至少不是以直观的方式.但是,从xcode 3.x导入的项目中,至少作为向后兼容性功能支持此功能.
有没有人知道一种方法来指定这些设置,而无需在旧的xcode中打开项目或为每个文件创建项目?
据我所知,C++定义map<a,b>::value_type为pair<const a,b>
如果我在地图中使用指针类型作为键类型会发生什么,即
std::map<const char*,int>::value_type::first_type = const char*
Run Code Online (Sandbox Code Playgroud)
正如我对上面的定义所期望的那样
std::map<const char*,int>::value_type::first_type = const char* const
Run Code Online (Sandbox Code Playgroud)
因为更合乎逻辑(因为否则我将被允许从地图迭代器中更改键值)?
我有一个iPhone应用程序,我想从隐藏状态栏开始,显示启动画面,并在加载要显示的内容时切换状态栏(这需要一些时间,因为它必须通过互联网加载),使用[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES].我希望我的内容视图在状态栏显示和隐藏后调整大小并正确定位.我希望我的应用程序能够以任何设备方向运行(可能不包括苹果指南中指定的自上而下的方向).
我的问题是我无法让应用程序显示出来.它在自动旋转后显示20pt的空白区域,或者在显示时隐藏在状态栏下方.
处理这个问题的正确方法应该是什么?
我还没有测试过它,但我猜这个问题会出现在来电吧.
编辑:
我会试着更好地解释问题所在.当应用程序启动时,状态栏隐藏,在窗口坐标系中,窗口可见区域的顶角在窗口坐标系中为0,0.然后我在状态栏中滑动.这不会改变窗口大小,因此0,0点现在隐藏在状态栏后面.窗口可见区域的左上角是0,20,我必须将视图移动到那些坐标(并将其正确调整为320*460).但是如果我旋转设备,然后回到原始位置,可见窗口区域的左上角坐标再次变为0,0,窗口现在大小为320*480.
一个解决方法是保持一个标志,告诉手机之前是否已经旋转,但是当我旋转到另一个位置然后回来时,是否有办法让窗口坐标不变?
我正在使用串行编程将连接的串行电缆连接到我的iPhone
我的代码如下
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
static struct termios gOriginalTTYAttrs;
static int OpenSerialPort()
{
int fileDescriptor = -1;
int handshake;
struct termios options;
// Open the serial port read/write, with no controlling terminal, and don't wait for a connection.
// …Run Code Online (Sandbox Code Playgroud) 假设我们有一对对矢量:
std::vector<std::pair<A,B>> v;
Run Code Online (Sandbox Code Playgroud)
其中A仅定义类型相等:
bool operator==(A const & lhs, A const & rhs) { ... }
Run Code Online (Sandbox Code Playgroud)
您如何对具有相同first元素的所有对最终关闭进行排序?要清楚,我希望实现的输出应该与以下内容相同:
std::unordered_multimap<A,B> m(v.begin(),v.end());
std::copy(m.begin(),m.end(),v.begin());
Run Code Online (Sandbox Code Playgroud)
但是,如果可能的话,我想:
编辑:其他具体信息.
在我的情况下,元素的数量不是特别大(我期望N = 10~1000),虽然我必须多次重复这种排序(~400)作为更大算法的一部分,并且已知的数据类型A相当大(它包含其中包含unordered_map~20 std::pair<uint32_t,uint32_t>的内容,这是阻止我发明排序,并且难以构建散列函数的结构)
在任何控制流语句中使用af#计算表达式的自定义操作都无法进行类型检查
error FS3086: A custom operation may not be used in conjunction with 'use',
'try/with', 'try/finally', 'if/then/else' or 'match' operators within this
computation expression
Run Code Online (Sandbox Code Playgroud)
为什么不允许这样做?什么是自定义操作,不允许重写此:
expr {
if a then
custom (x)
else
return (y)
}
Run Code Online (Sandbox Code Playgroud)
这样的事情:
expr {
return!
if a then
expr { custom (x) }
else
expr { return (y) }
}
Run Code Online (Sandbox Code Playgroud) 我已经定义了这个模板类结构:
template<typename T> struct Outer {
struct Inner { /* ...some stuff... */ };
};
Run Code Online (Sandbox Code Playgroud)
我想将Inner对象放入一个unordered_map(实际上,不是直接将它们而是它们的容器,因此直接在模板参数上指定散列对象的方法unordered_map不是一个好主意),因此我想hash为这些项目专门化类。
这将不起作用,因为编译器无法与Outer<T>::Inner实例化时指定的类型匹配hash:
namespace std {
template<typename T> struct hash<typename Outer<T>::Inner > {
size_t operator ()( typename Outer<T>::Inner const & obj )
{ /* ...some stuff... */ }
};
};
Run Code Online (Sandbox Code Playgroud)
有谁知道这个问题的解决方案?
是否可以从父目录执行make clean,它还递归清理所有子目录,而不必在每个子目录中包含makefile?
例如,目前在我的Makefile中,我有类似的东西:
SUBDIRS = src, src1
.PHONY: clean subdirs $(SUBDIRS)
clean: $(SUBDIRS)
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c
$(SUBDIRS):
$(MAKE) -C $(SUBDIRS) clean
Run Code Online (Sandbox Code Playgroud)
但是,这要求我在src和src1中都有一个Makefile.否则,我会得到错误
No rule to make target clean
Run Code Online (Sandbox Code Playgroud)
因为我只想在每个子目录中运行命令"rm -rf*.o ~core.depend .cmd*.ko*.mod.c",所以在每个子目录中都包含一个Makefile似乎是多余的.完全相同的线清洁.有没有办法简单地在每个子目录中运行相同的清洁命令?