小编Jen*_*zer的帖子

同时使用SSE2内在函数和gcc内联汇编程序

我试图在gcc中混合使用SSE2内在函数和内联汇编程序.但是如果我将变量指定为xmm0/register作为输入,那么在某些情况下我会遇到编译器错误.例:

#include <emmintrin.h>
int main() {
  __m128i test = _mm_setzero_si128(); 
  asm ("pxor %%xmm0, %%xmm0" : : "xmm0" (test) : );
}
Run Code Online (Sandbox Code Playgroud)

使用gcc版本4.6.1编译时,我得到:

>gcc asm_xmm.c
asm_xmm.c: In function ‘main’:
asm_xmm.c:10:3: error: matching constraint references invalid operand number
asm_xmm.c:7:5: error: matching constraint references invalid operand number
Run Code Online (Sandbox Code Playgroud)

奇怪的是,在我有其他输入变量/寄存器的相同情况下,它突然使用xmm0作为输入而不是xmm1等.而在另一种情况下,我能够指定xmm0-xmm4但不能在上面.对此有点困惑/沮丧:S

谢谢 :)

gcc sse inline-assembly intrinsics

7
推荐指数
1
解决办法
3368
查看次数

C++ 11非静态数据成员统一初始化失败,指针指向同一基类的其他类

我是一个老C-dude,试图通过将我的旧状态机框架从C移植到C++ 11来学习C++ 11.我的想法是为状态机本身创建一个类,然后为其中的状态设置嵌套类.状态可以是分层的,即超级和子状态.框架需要知道一个状态的超状态,为此我state *superstate在嵌套状态类中有一个指针().

我的问题是我打算通过直接在机器类中使用构造函数来设置超级指针,这应该可以在C++ 11中使用非静态数据成员初始化,通过使用统一初始化.但是有些原因substateB3{superstateA}在设置为另一种类型的状态/类时无法编译().但是如果我以后通过使用特定的函数(set_superstate)来设置它,它具有与构造函数相同的参数,它可以正常工作!并且有趣的是,如果我将superstate设置为相同类型的状态/类(substateB2{substateB1}),则接受构造函数.

我正在使用gcc 4.7.0(以获得对非静态数据成员初始值设定项的支持),这是我的代码:

// My state-machine framework (simplified)
struct machine {
  struct state {
    state()                  : superstate(nullptr) { }     // No superstate => toplevel state!
    state(state &superstate) : superstate(&superstate) { }
    state *superstate;
    void set_superstate(state &superstate) { this->superstate = &superstate; } // Non-ctor way to set superstate
  };
};

// An example of a specific state-machine using my framework
struct Machine : machine {
  struct SuperstateA : …
Run Code Online (Sandbox Code Playgroud)

c++ c++11

5
推荐指数
1
解决办法
1029
查看次数

CorePlot在iOS7 app/Xcode5中抛出异常

我有一个iOS7应用程序,我试图将CorePlot 1.4集成到(从属项目安装).

@property (nonatomic) CPTGraphHostingView *hostingView;
Run Code Online (Sandbox Code Playgroud)

_hostingView = [[CPTGraphHostingView alloc] initWithFrame:CGRectNull];
Run Code Online (Sandbox Code Playgroud)

(_hostingView受自动布局限制.)如果我然后添加图表:

CPTXYGraph *graph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
_hostingView.hostedGraph = graph;
Run Code Online (Sandbox Code Playgroud)

我首先得到这个例外:

-[CPTTextStyle attributes]: unrecognized selector sent to instance 0xa392900
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPTTextStyle attributes]: unrecognized selector sent to instance 0xa392900'
5   myapp                     0x00074325 -[CPTAxis updateAxisLabelsAtLocations:inRange:useMajorAxisLabels:] + 1141
6   myapp                     0x00075662 -[CPTAxis relabel] + 1202
Run Code Online (Sandbox Code Playgroud)

无奈之下,我已经updateAxisLabelsAtLocations:inRange:useMajorAxisLabels通过以下方式解决了这个问题:

NSDictionary *textAttributes = nil;
BOOL hasAttributedFormatter  = FALSE;
Run Code Online (Sandbox Code Playgroud)

然后得到下一个异常:

-[__NSCFString sizeWithTextStyle:]: unrecognized selector …
Run Code Online (Sandbox Code Playgroud)

core-plot ios7 xcode5

2
推荐指数
1
解决办法
2271
查看次数

为 UITableView 滑动操作设置自定义字体 (UIContextualAction)

你如何为 中的标题设置自定义字体UIContextualAction

我试过了,UIAppearance但没有任何运气......

干杯! :)

uitableview ios uitableviewrowaction uiswipeactionsconfiguration uicontextualaction

2
推荐指数
2
解决办法
2940
查看次数