小编Gri*_*rim的帖子

如何强制cdecl调用约定在特定头文件中声明的函数

您好我的VC2008项目使用stdcall调用约定.我有一个我使用的外部库,它使用cdecl命名约定构建,但是他们没有在函数的函数声明中提到调用约定.

我想知道VC是否有某种#pragma或其他关键字会强制整个头文件的特定调用约定

有点像extern"C"技巧,但对于调用约定:

extern "C" 
{
#include <file1.h>
#include <file2.h> 
}
Run Code Online (Sandbox Code Playgroud)

谁知道这样的?

c c++ visual-c++

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

从类方法返回作用域枚举时,命名空间混淆了

我在C++中有以下代码:

class Person
{
    public:
        enum Gender {Male, Female};

        Gender GetGender() const;
}
Run Code Online (Sandbox Code Playgroud)

我用这种方式将它包装在boost :: python中:

BOOST_PYTHON_MODULE(TestPython)
{
    scope the_scope = class_<Person>("Person")
        .def("GetGender", &Person::GetGender);

    enum_<Person::Gender>("Gender")
        .value(Male, Person::Male)
        .value(Female, Person::Female)
        .export_values();
}
Run Code Online (Sandbox Code Playgroud)

当我尝试person.GetGender()从Python 调用时,我得到以下异常:

Can't pickle : attribute lookup **PyBF.TestPython.Gender**.
It guesses the namespace of the Gender (which is actually **PyBF.TestPython.Person.Gender**) enum return type incorrectly.

如何告诉GetGender函数显式返回什么类型?

c++ python boost-python

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

让marionette.backbone与webpack热模块更换一起使用

我从这里使用了一个示例项目来设置一个带有热模块替换的webpack项目.然后我建立了一个示例骨干应用程序.

// main.js
import $ from 'jquery';
import Backbone from 'backbone';

import Router from './router';

window.app = window.app || {};

const app = new Backbone.Marionette.Application();
app.addRegions({content: '#content'});

app.on('start', () => {
    if (Backbone.history)
      Backbone.history.start({ pushState: true })
}

);

app.addInitializer(() => {
  return new Router();
});


$( () => { app.start() });

// HMR
if (module.hot) {
    module.hot.accept();
}
Run Code Online (Sandbox Code Playgroud)

我可以看到HRM根据[HMR] connected调试输出正在加载.当文件发生变化时,我可以看到它根据以下输出重建并推送到客户端的更新:

[HMR] Updated modules:
process-update.js?e13e:77 [HMR]  - ./app/backbone/views/template.hbs
process-update.js?e13e:77 [HMR]  - ./app/backbone/views/hello.js
process-update.js?e13e:77 [HMR]  - ./app/backbone/router.js …
Run Code Online (Sandbox Code Playgroud)

backbone.js webpack webpack-dev-server webpack-hmr

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