小编cos*_*cos的帖子

如何根据声明顺序对方法实现进行排序

是否有任何Visual Studio 2008加载项或宏来根据.h文件中声明的顺序对.cpp文件中的方法实现进行排序?编辑:任何最近的Visual Studio(2010年,2013年,2015年,2017年)

c++ add-in visual-studio

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

将任何类型的文件转换为带有c字符串的文件

请建议一个小的命令行实用程序(用于Windows)将文件从特定目录转换为有效的c文件.也许它可以用批处理命令完成?生成的文件应如下所示:

static const unsigned char some_file[] = {
    /* some_file.html */
    0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
    0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65
}

static const unsigned char some_other_file[] = {
    /* some_other_file.png*/
    0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
    0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c
}
Run Code Online (Sandbox Code Playgroud)

PS请不要建议Perl和Python端口.它们对于这项任务来说太沉重了.

PPS可能有人知道比bin2h更可定制的实用程序,但是比awt更重,更复杂?哪个可以解析几个文件并将它们放到一个C中.同时指定自定义变量名称(使用某种索引文件)也很棒.因此可以将其添加到构建过程中.

c c++ resources command-line file

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

使用指针模板参数

我有以下代码:

struct Port {
    int reg1;
    int reg2;
};

#define PORT1 ((Port *) 0x00010000); // absolutely compile-time constants
#define PORT2 ((Port *) 0x00020000);

template <Port * port>
class PortWrapper {
public:
    PortWrapper() {
        port->reg1 = 1;
        port->reg2 = 2;
    }
};

constexpr static const Port * const port1c = PORT1;

int main(int argc, char* argv[]) {
    PortWrapper<PORT1> port1; //Compiler says: error: could not convert template argument '65536u' to 'Port*'
    PortWrapper<port1c> port1; //Compiler says: error: 'port1c' is not a valid template …
Run Code Online (Sandbox Code Playgroud)

c++ templates

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

从一组有限的类静态强制转换为类

我想对一个集合中的一个类实现静态强制转换,作为可变参数模板参数传递:

struct Base {
    int tag_value;
};

struct Derived1 : public Base {
    static constexpr int tag = 1;
    Derived1() : Base{tag} {}
    int foo() { return 100; }
};

struct Derived2 : public Base {
    static constexpr int tag = 2;
    Derived2() : Base{tag} {}
    int foo() { return 200; }
};

struct Derived3 : public Base {
    static constexpr int tag = 3;
    Derived3() : Base{tag} {}
    int foo() { return 300; }
};

template <class ... Candidates, …
Run Code Online (Sandbox Code Playgroud)

c++ templates template-meta-programming variadic-templates c++17

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

嵌入式应用程序的浮点库

我正在为Cortex-M3开发程序.它没有浮点协处理器.标准C库可以模拟浮点运算,但由于它的大小,我不使用它.

有没有好的和免费的c库,可以模拟浮点运算,针对ARM处理器?目前,当我使用浮点运算符时,我有这样的链接错误:

undefined reference to `__adddf3'
undefined reference to `__subdf3'
undefined reference to `__divdf3'
undefined reference to `__extendsfdf2'
undefined reference to `__muldf3'
Run Code Online (Sandbox Code Playgroud)

所以可能这样的库应该实现它们.

c embedded floating-point

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