c++ 中__declspec 的用法
其实这两个关键字就是给编译器了一种保证,编译器信任他就不在进行一些检查操作了。
e.g
#include <stdio.h>
#include <stdlib.h>
#define M 800#define N 600#define P 700float * mempool, * memptr;
__declspec(restrict) float * ma(int size)
{
float * retval;
retval = memptr;
memptr += size;
return retval;
}
__declspec(restrict) float * init(int m, int n)
{
float * a;
int i, j;
int k=1;
a = ma(m * n);
if (!a) exit(1);
for (i=0; i<m; i++)
for (j=0; j<n; j++)
a[i*n+j] = 0.1/k++;
return a;
}
__declspec(noalias) void multiply(float * a, float * b, float * c)
{
int i, j, k;
for (j=0; j<P; j++)
for (i=0; i<M; i++)
for (k=0; k<N; k++)
c[i * P + j] = a[i * N + k] * b[k * P + j];
}
int main()
{
float * a, * b, * c;
mempool = (float *) malloc(sizeof(float) * (M*N + N*P + M*P));
if (!mempool)
puts("ERROR: Malloc returned null"); exit(1);
memptr = mempool;
a = init(M, N);
b = init(N, P);
c = init(M, P);
__declspec 关键字详细用法 __declspec 用于指定所给定类型的实例的与 ...在 C++中,默认情况下 const 为 static;但在 C 中是正确的,其默认情况下 ...
用法:__declspec ( extended-decl-modifier ) extended-decl-modifier 参数如下,...在 C++中,默认情况下 const 为 static; 但在 C 中是正确的,其默认情况下 ...
类的成员函数里调用虚函数需要 vtable 指针, 但是 class B 是不允许产生 ... c++ 中__declspec 的用法... 6页 免费 C语言中常用的三种排序方... 2页...
__declspec 的详细用法 __declspec 用于指定所给定类型的实例的与 Microsoft ...在 C++中,默认情况下 const 为 static;但在 C 中是正确的, 其默认情况下 ...
C++中&的用法总结_理学_高等教育_教育专区。C++中&的用法总结(例题详解哦)一种是按位与 1 & 2 = 0 一种是取地址 int* p = &a; 一种是声明引用,...
__declspec 关键字详细用法 2010-03-04 15:04 __declspec 用于指定所给定类型...在 C++中,默认情况下 const 为 static;但在 C 中是正确的,其默认情况下 ...
C++编程技巧,模板特化、模板偏特化就更是技巧性很强的东西,STL 中的 type_traits 充分借助模板特化的功能,实现了在程序编译期通过编译器来决定为每一处调用使用哪...
__declspec 关键字详细用法 ---李剑编辑 __declspec 用于指定所给定类型的实例...当然, 如果你 的 DLL 里全是 C++ 的类的话,你无法在 DEF 里指定导出的...
我要用。一般用于使用某个 dll 的 exe 中 不使用 __declspec(dllimport) ... __declspec 和 DLL导出函... 8页 免费 C++关键字 暂无评价 4页 免费 ...
热门文档