我正在为嵌入式系统编写软件.
我们使用指针访问FPGA器件的寄存器.
一些寄存器是只读的,而另一些寄存器是只写的.
只读寄存器在读取时将产生未定义的值.
我想定义一个指针类型,允许编译器检测何时从只写寄存器(也称为解除引用)读取值.
只使用C语言语法创建只写指针吗?
(我们正在使用C开发第一个原型,但是在第二代转向C++.)
如何在C++中创建高效的只写指针?(请记住,这不是跟踪动态内存中的项目,而是访问硬件地址.)
此代码用于安全性和质量最受关注的嵌入式系统.
我想Doxygen忽略,绕过,而不是搜索我项目的以下目录:
*/.svn/*
*/docs/*
*/Properties/*
*/bin/*
Run Code Online (Sandbox Code Playgroud)
根据Doxygen FAQ:
How can I exclude all test directories from my directory tree?
Simply put an exclude pattern like this in the configuration file:
EXCLUDE_PATTERNS = */test/*
Run Code Online (Sandbox Code Playgroud)
所以,我的Doxygen文件看起来像这样:
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories. Note that the wildcards are matched
# against the file with absolute path, …Run Code Online (Sandbox Code Playgroud) 为什么编译器似乎对没有做任何事情并且不消除它们的循环有礼貌?
C标准是否需要循环需要一些时间?
例如,以下代码:
void foo(void) {
while(1) {
for(int k = 0; k < 1000000000; ++k);
printf("Foo\n");
}
}
Run Code Online (Sandbox Code Playgroud)
运行速度比这个慢:
void foo(void) {
while(1) {
for(int k = 0; k < 1000; ++k);
printf("Foo\n");
}
}
Run Code Online (Sandbox Code Playgroud)
即使有-O3优化水平.我希望删除允许的空循环,从而在两个代码上获得相同的速度.
"花费的时间"是否应该由编译器保留的副作用?
我遇到了Doxygen识别命名空间和模块的问题.我认为问题围绕着是\addtogroup在命名空间内还是在命名空间之外.
/*!
* \addtogroup Records
* @{
*/
//! Generic record interfaces and implementations
namespace Records
{
//! Describes the record interface
class Interface;
} // End namespace Records
/*! @} End of Doxygen Groups*/
Run Code Online (Sandbox Code Playgroud)
//! Generic record interfaces and implementations
namespace Records
{
/*!
* \addtogroup Records
* @{
*/
//! Describes the record interface
class Interface;
/*! @} End of Doxygen Groups*/
} // End namespace Records
Run Code Online (Sandbox Code Playgroud)
我希望它namespace Records出现在Doxygen Namespaces …
c++ doxygen namespaces documentation-generation doxygen-addtogroup
指针可以声明为指向可变(非常量)数据或指向常量数据的指针.
可以将指针定义为指向函数.
我的同事和我正在讨论使用带有指针的"const",并且出现了关于使用const函数指针的问题.
以下是一些问题:
typedef void (*Function_Pointer)(void); // Pointer to void function returning void.
void function_a(Function_Pointer p_func); // Example 1.
void function_b(const Function_Pointer p_func); // Example 2.
void function_c(Function_Pointer const p_func); // Example 3.
void function_d(const Function_Pointer const p_func); // Example 4.
Run Code Online (Sandbox Code Playgroud)
上述声明是将函数指针视为指向内部类型的指针的示例.
数据,变量或存储器指针允许上述组合.
所以问题是:函数指针是否具有相同的组合以及指向const函数的指针(例如示例2)是什么意思?
我有一个头文件,将包含大量(30+)内联函数.
我没有让读者滚动或搜索内联函数的定义(实现),而是希望有一个前向声明部分,它声明函数声明以及描述函数的注释.本节将允许读者了解如何使用函数或查找函数,而无需向下滚动到实现.
此外,我希望读者养成使用函数的习惯,而不必看到他们的实现.
独立函数的前向声明的语法是什么?
{这适用于C99和C++}
仅供参考,我使用IAR Workbench C编译器设置使用C99.
在C++中,map基于黑红树,因此,插入/删除功能将花费O(logn),而hash_map基于哈希.
但我在徘徊,基于什么数据结构设置?
集合按地图排序,因此,是否也基于黑红树设置?
它的键和值如何存储在那棵树中?
如果是这样,unorder_set的数据结构是什么?谢谢!
我想知道floatGCC中的a的大小,而不必运行编译器.我知道一个选项是编写一个小函数并让编译器打印出一个汇编列表.
有limits.h,包含最小值和最大值,但是有类似的东西告诉不同的隐式类型的大小?
我在Windows 7 x64上使用GCC; 目标平台是ARM7 32位模式.语言是C.
我有一个宏将行号和文件名传递给错误处理程序:
#define SYSTEM_FAILURE (error_code, comment) \
System_Failure((error_code), (comment), __LINE__, __FILE__);
Run Code Online (Sandbox Code Playgroud)
__LINE__在内联函数中使用时如何解决?
file.h:
inline int divide(int x, int y)
{
if (y == 0)
{
SYSTEM_FAILURE(ENUM_DIVIDE_BY_ZERO, "divide by zero error");
}
return x/y;
}
Run Code Online (Sandbox Code Playgroud)
将__LINE__包含头文件中的行号,或调用内联函数的源文件的行号(假设编译器在源代码中执行"粘贴")?
c++ ×7
c ×6
doxygen ×2
inline ×2
c99 ×1
destructor ×1
gcc ×1
line ×1
namespaces ×1
parameters ×1
pointers ×1
readonly ×1
set ×1
sizeof ×1