0
我必須修改Mac代碼才能使其在Windows上工作,或者至少需要編譯,但valloc似乎存在問題。在Windows上找不到valloc標識符
它說:error C3861: 'valloc': identifier not found.
這是如何使用它:
#ifndef _XOPEN_SOURCE_EXTENDED 1
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#include <stdlib.h>
#include <queue>
#include "ArrayArithmetic.h"
#include "MessageObject.h"
#if __SSE__
// allocate memory aligned to 16-bytes memory boundary
#define ALLOC_ALIGNED_BUFFER(_numBytes) (float *) _mm_malloc(_numBytes, 16)
#define FREE_ALIGNED_BUFFER(_buffer) _mm_free(_buffer)
#else
// NOTE(mhroth): valloc seems to work well, but is deprecated!
#define ALLOC_ALIGNED_BUFFER(_numBytes) (float *) valloc(_numBytes)
#define FREE_ALIGNED_BUFFER(_buffer) free(_buffer)
#endif
我有好包括,至少我是這麼認爲的。 不,我真的不知道它來自哪裏,在Windows上是否可以使用valloc
?
我在Windows 8.1中的工作與Visual Studio 2010
您應該標記語言。我猜C,但你包括''。 –
crashmstr
2014-10-31 14:51:13
「'valloc()'函數分配內存的大小字節並返回一個指向已分配內存的指針,分配的內存在頁邊界上對齊。」 [(源)](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/valloc.3.html)。如果頁面對齊在這段代碼中很重要(誰知道?),你將不得不寫一個替代品。 – usr2564301 2014-10-31 14:53:54
..這可能有助於Windows:http://stackoverflow.com/questions/10862121/undefined-reference-to-posix-memalign-using-mingw32 – usr2564301 2014-10-31 14:55:54