我正在使用RHEL 5.3,随gcc 4.1.2一起提供并提升1.33.因此,没有boost :: unorded_map,没有make_shared()工厂函数来创建boost :: shared_ptr以及较新版本的boost中提供的其他功能.
是否有更新版本的boost与gcc版本兼容?如果是,升级如何执行?
我有一个代码(简化版):
#define MESSAGE_SIZE_MAX 1024
#defined MESSAGE_COUNT_MAX 20
class MyClass {
public:
.. some stuff
private:
unsigned char m_messageStorage[MESSAGE_COUNT_MAX*MESSAGE_SIZE_MAX];
};
Run Code Online (Sandbox Code Playgroud)
我不喜欢定义,它们对MyCalss的所有用户都是可见的.
我怎么能用C++风格呢?
谢谢迪马
我的项目有很多包含几个项目的解决方案.有2个配置:
我们有第三方图书馆.我们是否应该为每个配置提供2个版本(使用/ MTd编译的/ MT和Debug版本编译的发行版本),或者只有一个版本(/ MT或/ MTd)?
谢谢迪马
我正在使用gcc 4.1.2在RHEL 5.1 64位平台上运行.
我有一个实用功能:
void str_concat(char *buff, int buffSize, ...);
Run Code Online (Sandbox Code Playgroud)
concats char*在可变参数列表(...)中传递,而最后一个参数应为NULL,以指定参数的结尾.在64位系统上,NULL是8个字节.
现在来问题了.我的应用程序直接/间接包含2个stddef.h文件.
第一个是/usr/include/linux/stddef.h,它定义NULL如下:
#undef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif
Run Code Online (Sandbox Code Playgroud)
第二个是/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include/stddef.h
#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL /* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else /* G++ */
#ifndef __cplusplus
#define NULL ((void *)0)
#else /* C++ */
#define NULL 0
#endif /* C++ */
#endif /* G++ */
#endif /* …Run Code Online (Sandbox Code Playgroud) 为什么元组文档要使用,例如:
#include "boost/tuple/tuple.hpp"
Run Code Online (Sandbox Code Playgroud)
并不是
#include <boost/tuple/tuple.hpp>
Run Code Online (Sandbox Code Playgroud)
我知道我的代码不可能有一个名为"boost/tuple/tuple.hpp"的文件,但使用include <>明确表示不要查看curent目录.
那是什么原因?
c++ compiler-construction coding-style conventions c-preprocessor
假设我有方法:
void foo(const std::string& s);
Run Code Online (Sandbox Code Playgroud)
我可以创建boost :: function:
boost::function<void(const std::string&)> f = boost::bind(foo, temp);
Run Code Online (Sandbox Code Playgroud)
其中temp是char*,在f被调用之前被删除.
有可能做这样的事情:
const char* str = "AaBbCc";
string str_up = boost::to_upper_copy(str); // str_up will be "AABBCC"
Run Code Online (Sandbox Code Playgroud)
最后一行无法编译.
当然我可以如下,但它不那么"规范":
const char* str = "AaBbCc";
string str_up = str;
boost::to_upper(str_up);
Run Code Online (Sandbox Code Playgroud) 我有一个由几个项目组成的Visual Studio 2008解决方案.每个项目中只有一些头文件代表从项目构建的库的API.
在编译之前,Visual Studio中有没有办法将文件复制到公共目录?(我想这样做是为了防止包含无意识的头文件我不应该这样做)
谢谢迪马
我正在考虑在团队范围内使用ccache和gcc编译代码(同一台机器上的所有开发人员都将使用相同的ccache缓存).
由于我们谈论的是商业产品,因此编制的"正确性"是首要任务.
这里有问题:
使用ccache的编译是安全 /可重现的吗?是否有一些异常情况,ccache错误地认为缓存命中.
如果我签出源代码并编译它,我希望每次重复一个新的编译过程时都会收到相同的产品(完全相同的库/二进制文件).这是商业产品必须的.
谢谢
我正在使用gcc 4.3.2.
我有以下代码(简化):
#include <cstdlib>
template<int SIZE>
class Buffer
{
public:
explicit Buffer(const char *p = NULL) {}
explicit Buffer(const Buffer &other);
const char *c_str() const { return m_buffer; }
private:
char m_buffer[SIZE];
};
typedef Buffer<10> A;
typedef Buffer<20> B;
void Foo(A a) {
}
int main()
{
B b;
Foo(b.c_str()); // line 25 fails compilation
return 1;
}
Run Code Online (Sandbox Code Playgroud)
编译产量:
test.cpp: In function ‘int main()’:
test.cpp:25: error: conversion from ‘const char*’ to non-scalar type ‘A’ requested
Run Code Online (Sandbox Code Playgroud)
但是有接收const char*的c-tor.
UDP:
如果我从第一个c-tor中删除了我收到的 …
c++ ×9
gcc ×4
boost ×3
compilation ×3
64-bit ×1
arrays ×1
boost-bind ×1
ccache ×1
coding-style ×1
conventions ×1
header ×1
linker ×1
linux ×1
null ×1
string ×1