奇妙的内在功能行为VS2010,这是一个错误吗? [英] Wierd intrinsic function behaviour VS2010, is this a bug?

查看:90
本文介绍了奇妙的内在功能行为VS2010,这是一个错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的代码

I have code like this

void* __cdecl memcpy( void* dest, const void* src, size_t count );
char* __cdecl strcpy( char* strDest, const char* strSource );

#pragma intrinsic(memcpy)
void* CCompiler::memcpy( void* dest, const void* src, size_t count )
{
  return ::memcpy( dest, src, count );
}

#pragma intrinsic(strcpy)
char* CCompiler::strcpy( char* strDest, const char* strSrouce )
{
  return ::strcpy( strDest, strSource );
}

#pragma function(memcpy)
#pragma function(strcpy)





尽管strcpy非常高兴我得到一个 LNK2019未解析的外部符号_memcpy在函数public:void * __cdecl nsCompiler :: CCompiler :: memcpy(void *,void const *,unsigned int)

当我尝试将其构建为Dll时。

FYI nsCompiler :: CCompiler已导出,我知道这样做是正确的。



尽管memcpy内在不可用,但没有警告警告级别4并且没有编译错误声称它无法生成nsCompiler :: CCompiler :: memcpy



任何帮助,已知错误指针或变通方法都将非常感谢。



Whereas strcpy is perfectly happy I get a LNK2019 unresolved external symbol _memcpy referenced in function "public: void * __cdecl nsCompiler::CCompiler::memcpy(void*,void const*,unsigned int)"
when I try to build the this into a Dll.
FYI nsCompiler::CCompiler is exported and I know that''s done right.

No warning that memcpy intrinsic is not available despite warning level 4 and no compile error claiming it can''t generate nsCompiler::CCompiler::memcpy

Any help, known bug pointers, or workarounds would be much appreciated.

推荐答案

只是猜测蓝色:内在的pragma文档说:......编译器可以调用函数而不是用内联指令替换函数调用,如果它会带来更好的表现。因此,在memcpy的情况下,编译器可能决定调用库函数而不生成内联代码(因为它可能对strcpy执行)。现在,如果您没有正确设置链接器设置以在运行时库中链接,那么可能会产生未解析的外部链接。
Just a guess into the blue: The intrinsic pragma documentation says: "... The compiler may call the function and not replace the function call with inline instructions, if it will result in better performance." So in case of memcpy the compiler might decide to call the library function and not generate inline code (as it probably did for strcpy). Now, if you haven''t set the linker settings correctly to link in the runtime library, that might produce the unresolved external.


这篇关于奇妙的内在功能行为VS2010,这是一个错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆