小编jwf*_*arn的帖子

源文件编码或执行字符集会改变 wchar_t 内部保存的方式吗?

这里的东西(https://docs.microsoft.com/en-us/cpp/build/reference/source-charset-set-source-character-set),我知道所有关于VC ++/source-charset/execution-charset

所以有 3 件事我需要保持不变(如果有任何错误,请纠正我):

  1. 源文件编码
  2. /source-charset 设置(确定编译器如何解释我的源文件)
  3. /execution-charset 设置(确定编译器如何将第 2 阶段的“输出内容”解释为可执行文件。

所以,如果有我保存源文件encodingA,设置/source-charset/execution-charset作为encodingA,并有代码wchar_t c = L'é';char16_t c = u'é'; 或者char32_t c = U'é'

程序会é根据encodingA我在“解释”期间选择的代码单元来更改代码单元吗?

或者é无论我选择什么编码,代码单元都不会改变?

(不要关心控制台输出)

c++

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

通过c ++中的类引用访问变量

我有一个c ++类,其中一部分在下面

class Node{
    public:
       vector<string> getNames() const;
    private:
        vector<string> names_;
};
vector<string> Node::getNames(){
    return names_;
}
Run Code Online (Sandbox Code Playgroud)

函数getNames()传递向量的副本.我如何修改我的类,以便我可以从我声明Node对象而不是传递副本的任何其他类引用'const reference'向量'?

c++

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

用于c ++的Makefile生成器?

做以下构建系统:cmake,jam和bjam还生成像qmake那样的makefile吗?MS visual c ++使用什么实用程序来生成make文件?

c++ makefile cmake bjam

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

CMake GLOB和source_group是否兼容?

我在"Visual Studio 10"生成器上使用CMake 2.8.1(在Windows上).GLOB并且source_group似乎没有一起工作.有没有办法让这个工作?

file( GLOB ... )用来创建.cpp文件列表,然后用于在生成的Visual Studio项目中source_group创建过滤器:

# C:\Users\My Name\hello\CMakeLists.txt
cmake_minimum_required( VERSION 2.8 )
project( hello_proj )
file( GLOB HELLO_SRCS *.cpp )
message( "HELLO_SRCS="${HELLO_SRCS} )
#source_group( hello_group ${HELLO_SRCS} ) #line 6: uncomment to get error
add_executable( hello_exec ${HELLO_SRCS} )
Run Code Online (Sandbox Code Playgroud)

第6行注释掉,项目生成正常:

C:\Users\My Name\hello>cmake .
HELLO_SRCS=C:/Users/My Name/hello/hello.cppC:/Users/My Name/hello/print_line.cpp
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/My Name/hello
Run Code Online (Sandbox Code Playgroud)

第6行没有评论,我收到一个错误:

C:\Users\My Name\hello>cmake …
Run Code Online (Sandbox Code Playgroud)

cmake

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

无法捕获C++异常

我想在尝试使用某些类的复制构造函数时捕获异常,这会抛出.

#include <iostream>

class dont_copy_me {
public:
    dont_copy_me() {}
    dont_copy_me(const dont_copy_me& rhs) {throw;}
    dont_copy_me(dont_copy_me&& rhs) {throw;}
    ~dont_copy_me() {}
};

int main() {
    try {
        dont_copy_me obj;
        dont_copy_me obj_1(obj);
    } catch(...) {
        std::cout << "exception caught" << std::endl;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但我一直在努力

terminate called without an active exception
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)

怎么了?如何捕获复制构造函数抛出的异常?(因为那是我需要的)

c++ exception

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

标签 统计

c++ ×4

cmake ×2

bjam ×1

exception ×1

makefile ×1