
c++
文章平均质量分 73
rx_wen
这个作者很懒,什么都没留下…
展开
-
Macro expansion and Assembly code
We know that compiler will expand macros before it actually compiles the code. Sometimes it's useful if we can view the result of the expansion, especially when we use macro to implement some functions. Here is how:Microsoft C++ compiler: cl.e原创 2009-04-21 21:44:00 · 520 阅读 · 0 评论 -
use memcmp to compare objects?
I came across a question regarding c++, is it more efficient to use memcmp to determine equality of two objects of the same type.This is not a question regarding efficiency at all, it's about correctness. Using memcmp to compare two objects MAY be correct原创 2009-12-11 09:13:00 · 527 阅读 · 0 评论 -
understanding dynamic cast
dynamic_cast is a run-time type conversion operator and it ensures only valid conversion can success. The expression dynamic_cast(src) converts expression src to dest_type if appropriate, fails otherwise. Unlike static_cast, it performs type checking at ru原创 2009-10-14 12:46:00 · 431 阅读 · 0 评论 -
performance impact of printf
Logging is a widely used debugging means. As a way of implementing logging, I saw printf used in a lot of places. It's so quick and easy to use printf to examine the behavior of an application. But it also has heavy impact of the performance of the applica原创 2010-07-07 13:23:00 · 491 阅读 · 0 评论 -
why offsetof can use null pointer
offsetof is a widely used means in c and c++ to find out the offset of a member variable in its struct or class. The most normal way to implement it is via following macro: #define offsetof(st, m) ((size_t) ( (char *)&((st *)(0))->m - (char *)0 ))The idea原创 2010-07-18 14:30:00 · 495 阅读 · 0 评论