小编Hik*_*ari的帖子

为什么发布版本memset比visual studio 2012中的调试版本慢?

为什么发布版本memset比visual studio 2012中的调试版本慢?在视觉sutido 2010中,也是这样的结果.我的电脑:

英特尔酷睿i7-3770 3.40GHz 8G内存操作系统:windows 7 sp1 64bit

这是我的测试代码:

#include <boost/progress.hpp>

int main()
{
    const int Size = 1000*1024*1024;
    char* Data = (char*)malloc(Size);

#ifdef _DEBUG
    printf_s("debug\n");
#else
    printf_s("release\n");
#endif

    boost::progress_timer timer;
    memset(Data, 0, Size);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

release
0.27 s

debug
0.06 s
Run Code Online (Sandbox Code Playgroud)

编辑:

if i change code to this, it will get the same result:

#include <boost/progress.hpp>

int main()
{
    const int Size = 1000*1024*1024;
    char* Data = (char*)malloc(Size);
    memset(Data, 1, Size);

#ifdef _DEBUG
    printf_s("debug\n");
#else …
Run Code Online (Sandbox Code Playgroud)

c++ memset visual-studio-2012

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

我们可以实现一个max或min宏,它可以接受可变参数(两个以上的参数)

我想实现一个新的max / min宏,该宏可以采用两个以上的参数,例如:

#define max( ... ) ...
Run Code Online (Sandbox Code Playgroud)

然后,我可以像这样使用它:

max( p0, p1, p2, p3 )
max( 2, 4, 100 )
max( 1,2,3,4,5,6,7 ) -> 7
Run Code Online (Sandbox Code Playgroud)

这个宏是否可以帮助我们实现该宏?

#define PP_EXPAND(X) X
#define PP_ARG_COUNT(...) PP_EXPAND(PP_ARG_POPER(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
#define PP_ARG_POPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N

#define PP_ARG_AT(Index, ...) PP_ARG_AT_##Index(__VA_ARGS__)
#define PP_ARG_AT_0(...)  PP_EXPAND(PP_ARG_POPER(_1, _2, _3, _4, _5, …
Run Code Online (Sandbox Code Playgroud)

c++ variadic-macros boost-preprocessor

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

链接器合成中的“紧凑展开信息”是什么意思

当我分析xcode生成的链接映射文件时,在链接器合成部分中,有一个名为“compact unwind info”的数据。

compact unwind info 858.57KB    858572  Unchecked
Run Code Online (Sandbox Code Playgroud)

大约需要858kb的空间大小。我想知道这个空间中的实际数据是什么。有什么办法可以减小这个尺寸吗?

链接器合成部分的总输出:

compact unwind info 858.57KB
helper helper   24B
objc image info 8B
non-lazy-pointer    8B
non-lazy-pointer-to-local: dyld_stub_binder 8B
non-lazy-pointer-to-local: _vm_page_size    8B
non-lazy-pointer-to-local: _tanh    8B
non-lazy-pointer-to-local: _tan 8B
non-lazy-pointer-to-local: _strdup  8B
non-lazy-pointer-to-local: _strcmp  8B
non-lazy-pointer-to-local: _sinh    8B
non-lazy-pointer-to-local: _sin 8B
non-lazy-pointer-to-local: _realloc 8B
non-lazy-pointer-to-local: _protocol_getName    8B
non-lazy-pointer-to-local: _object_getIndexedIvars  8B
non-lazy-pointer-to-local: _objc_readClassPair  8B
non-lazy-pointer-to-local: _objc_lookUpClass    8B
non-lazy-pointer-to-local: _objc_getRequiredClass   8B
non-lazy-pointer-to-local: _objc_getProtocol    8B
non-lazy-pointer-to-local: _objc_getMetaClass   8B
non-lazy-pointer-to-local: _objc_getClass   8B
non-lazy-pointer-to-local: _objc_copyClassNamesForImage 8B
non-lazy-pointer-to-local: _objc_allocateClassPair …
Run Code Online (Sandbox Code Playgroud)

xcode linker text-segmentation

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

xcode下的vsnprintf函数和其他平台的vsnprintf有什么区别吗?

我写了一个非常简单的测试代码来测试vsnprintf,但是在xcode和Visual Studio环境下,结果有很大不同。测试代码如下:

\n
#define  _CRT_SECURE_NO_WARNINGS\n#include <iostream>\n#include <string.h>\n#include <cstdarg>\n\n\nvoid p(const char* fmt, ...)\n{\n    static const int DefaultLength = 256;\n    char defaultBuf[DefaultLength] = { 0 };\n    \n    va_list args;\n    va_start(args, fmt);\n    \n    vsprintf(defaultBuf, fmt, args);\n    printf("%s\\n", defaultBuf);\n    \n    memset(defaultBuf, 0, sizeof(defaultBuf));\n    vsnprintf(defaultBuf, DefaultLength, fmt, args);\n    printf("%s\\n", defaultBuf);\n    va_end(args);\n}\n\nint main(int argc, const char* argv[])\n{\n    // if you uncomment this line(std::cout ...), it will crash at vsnprintf in xcode\n    std::cout << "Tests...!\\n";\n    \n    p("Create:%s(%d)", "I\'m A String", 0x16);\n\n    return 0;\n}\n
Run Code Online (Sandbox Code Playgroud)\n

这是 Visual Studio …

c c++ xcode printf visual-studio

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

如何使我的 C# dll 程序集在 Visual Studio 对象浏览器中包含注释文本?

如果我在 Visual Studio 对象浏览器中打开此程序集,我发现系统 dll 包含注释文本,如下所示: 在此输入图像描述 你可以看到,有评论文字。但我的程序集不包含此内容,我已为这些属性编写注释文本。 在此输入图像描述 所以我想知道,如何为我的 dll 程序添加这些信息?

c#

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