- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写 CUDA 程序,为 BMP 文件添加模糊效果。我编写了在 CPU 上执行此操作的工作程序,现在我尝试将代码转换为 CUDA。这是我想在 CUDA 上使用的函数:
void blur(bitmap_header* hp, unsigned char *data)
{
int xx,yy,x,y, avgB, avgG, avgR, ile;
int blurSize = 5;
for(xx = 0; xx < hp->width; xx++)
{
for(yy = 0; yy < hp->height; yy++)
{
avgB = avgG = avgR = 0;
ile = 0;
for(x = xx; x < hp->width && x < xx + blurSize; x++)
{
for(y = yy; y < hp->height && y < yy + blurSize; y++)
{
avgB += data[x*3 + y*hp->width*3 + 0];
avgG += data[x*3 + y*hp->width*3 + 1];
avgR += data[x*3 + y*hp->width*3 + 2];
ile++;
}
}
avgB = avgB / ile;
avgG = avgG / ile;
avgR = avgR / ile;
data[xx*3 + yy*hp->width*3 + 0] = avgB;
data[xx*3 + yy*hp->width*3 + 1] = avgG;
data[xx*3 + yy*hp->width*3 + 2] = avgR;
}
}
}
如何将此函数转换为在 CUDA 设备上运行?每个教程仅涵盖一个 for 循环并使用
int i = threadIdx.x
我之前关于这个程序的问题: Blur effect on bitmap using C
编辑
带有 CUDA 编辑的完整代码:
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#pragma pack(push,1)
/* Windows 3.x bitmap file header */
typedef struct {
char filetype[2]; /* magic - always 'B' 'M' */
unsigned int filesize;
short reserved1;
short reserved2;
unsigned int dataoffset; /* offset in bytes to actual bitmap data */
} file_header;
/* Windows 3.x bitmap full header, including file header */
typedef struct {
file_header fileheader;
unsigned int headersize;
int width;
int height;
short planes;
short bitsperpixel; /* we only support the value 24 here */
unsigned int compression; /* we do not support compression */
unsigned int bitmapsize;
int horizontalres;
int verticalres;
unsigned int numcolors;
unsigned int importantcolors;
} bitmap_header;
#pragma pack(pop)
__global__ void blur(bitmap_header* hp, unsigned char *data)
{
int xx,yy,x,y, avgB, avgG, avgR, ile;
int blurSize = 5;
xx = blockIdy.y * blockDim.y + threadIdx.y;
yy = blockIdx.x * blockDim.x + threadIdx.x;
if(xx >= hp->width || yy >= hp->height)
return;
avgB = avgG = avgR = 0;
ile = 0;
for(x = xx; x < hp->width && x < xx + blurSize; x++)
{
for(y = yy; y < hp->height && y < yy + blurSize; y++)
{
avgB += data[x*3 + y*hp->width*3 + 0];
avgG += data[x*3 + y*hp->width*3 + 1];
avgR += data[x*3 + y*hp->width*3 + 2];
ile++;
}
}
avgB = avgB / ile;
avgG = avgG / ile;
avgR = avgR / ile;
data[xx*3 + yy*hp->width*3 + 0] = avgB;
data[xx*3 + yy*hp->width*3 + 1] = avgG;
data[xx*3 + yy*hp->width*3 + 2] = avgR;
}
int filter(char* input, char *output)
{
//variable dec:
FILE *fp,*out;
bitmap_header* hp;
bitmap_header* d_hp;
unsigned char *data;
unsigned char *d_data;
//Open input file:
fp = fopen(input, "r");
if(fp==NULL)
return 1;
//Read the input file headers:
hp=(bitmap_header*)malloc(sizeof(bitmap_header));
cudaMalloc( &d_hp, (sizeof(bitmap_header));
if(hp==NULL)
return 1;
fread(hp, sizeof(bitmap_header), 1, fp);
cudaMemcpy(d_hp, &hp, (sizeof(bitmap_header), cudaMemcpyHostToDevice);
//Read the data of the image:
data = (unsigned char*)malloc(sizeof(char)*hp->bitmapsize);
cudaMalloc( &d_data, (sizeof(char)*hp->bitmapsize));
fseek(fp,sizeof(char)*hp->fileheader.dataoffset,SEEK_SET);
fread(data,sizeof(char),hp->bitmapsize, fp);
cudaMemcpy(d_data, &data, (sizeof(char)*hp->bitmapsize), cudaMemcpyHostToDevice);
dim3 block(16,16);
dim3 grid ( (hp->height + 15)/16, (hp->width + 15)/16 );
blur<<<grid,block>>>(d_hp, d_data);
cudaMemcpy(data, d_data, (sizeof(char)*hp->bitmapsize), cudaMemcpyDeviceToHost);
//Open output file:
out = fopen(output, "wb");
if(out==NULL)
{
fclose(fp);
free(hp);
free(data);
cudaFree(d_data);
cudaFree(d_hp);
return 1;
}
fwrite(hp,sizeof(char),sizeof(bitmap_header),out);
fseek(out,sizeof(char)*hp->fileheader.dataoffset,SEEK_SET);
fwrite(data,sizeof(char),hp->bitmapsize,out);
fclose(fp);
fclose(out);
free(hp);
free(data);
cudaFree(d_data);
cudaFree(d_hp);
return 0;
}
int main(int argc, char* argv[])
{
int frames;
int frame = 1;
char path[100000];
system("rd /s/q temp");
system("mkdir temp");
system("cls");
printf("Zapis wszystkich klatek do folderu temp.\n");
system("ffmpeg.exe -i test.mp4 -r 29.970 -vcodec bmp temp/%d.bmp");
printf("Ile jest klatek w folderze temp?\n");
scanf("%d", &frames);
for(frame = 1;frame<=frames;frame++)
{
sprintf(path,"temp\\%d.bmp",frame);
printf("Nakladam filtr na ");
printf(path);
printf("\n");
filter(path,path);
}
system("cls");
printf("Wszystkie klatki do filmu mp4.\n");
system("ffmpeg -r 29.970 -i temp/%d.bmp -c:v libx264 -preset slow -crf 21 temp/out.mp4");
system("cls");
printf("Wyciecie dzwieku z filmu do mp3\n");
system("ffmpeg -i test.mp4 -vn -ar 44100 -ac 2 -ab 192 -f wav temp/sound.wav");
system("cls");
printf("Polaczenie mp3 z mp4.\n");
system("ffmpeg -i temp/sound.wav -i temp/out.mp4 final.mp4");
system("cls");
printf("Delete ");
system("rd /s temp");
system("pause");
return 0;
}
完整错误列表:
Warning 1 warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release. C:\Users\Karpińscy\documents\visual studio 2012\Projects\blur\blur\nvcc blur
Error 2 error : identifier "blockIdy" is undefined C:\Users\Karpi˝scy\documents\visual studio 2012\Projects\blur\blur\kernel.cu blur
Error 3 error : expected a ")" C:\Users\Karpi˝scy\documents\visual studio 2012\Projects\blur\blur\kernel.cu blur
Warning 4 warning : expression has no effect C:\Users\Karpi˝scy\documents\visual studio 2012\Projects\blur\blur\kernel.cu blur
Error 5 error : expected a ")" C:\Users\Karpi˝scy\documents\visual studio 2012\Projects\blur\blur\kernel.cu blur
Error 6 error : too few arguments in function call C:\Users\Karpi˝scy\documents\visual studio 2012\Projects\blur\blur\kernel.cu blur
Error 7 error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2012 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -G -maxrregcount=0 --machine 32 --compile -cudart static -I -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj "C:\Users\Karpińscy\documents\visual studio 2012\Projects\blur\blur\kernel.cu"" exited with code 2. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 6.0.targets 597 9 blur
8 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 33 1 blur
9 IntelliSense: expected a ';' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 33 12 blur
10 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 56 4 blur
11 IntelliSense: expected a ';' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 56 9 blur
12 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 57 4 blur
13 IntelliSense: expected a ';' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 57 7 blur
14 IntelliSense: expected a declaration c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 58 3 blur
15 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 62 2 blur
16 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 63 2 blur
17 IntelliSense: identifier "xx" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 65 7 blur
18 IntelliSense: identifier "yy" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 65 14 blur
19 IntelliSense: identifier "avgB" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 65 36 blur
20 IntelliSense: identifier "xx" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 66 7 blur
21 IntelliSense: identifier "yy" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 66 14 blur
22 IntelliSense: identifier "xx" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 67 7 blur
23 IntelliSense: identifier "yy" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 67 14 blur
24 IntelliSense: expected a declaration c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 68 1 blur
25 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 94 5 blur
26 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 95 2 blur
27 IntelliSense: identifier "d_data" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 95 15 blur
28 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 95 21 blur
29 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 97 5 blur
30 IntelliSense: identifier "fp" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 97 11 blur
31 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 97 13 blur
32 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 98 5 blur
33 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 98 15 blur
34 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 99 2 blur
35 IntelliSense: identifier "d_data" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 99 13 blur
36 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 99 19 blur
37 IntelliSense: identifier "dim3" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 102 2 blur
38 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 102 15 blur
39 IntelliSense: identifier "dim3" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 103 2 blur
40 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 103 34 blur
41 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 105 2 blur
42 IntelliSense: expected a ';' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 105 6 blur
43 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 106 2 blur
44 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 106 17 blur
45 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 109 2 blur
46 IntelliSense: identifier "output" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 109 14 blur
47 IntelliSense: expected a declaration c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 110 2 blur
48 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 122 5 blur
49 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 122 14 blur
50 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 123 5 blur
51 IntelliSense: expected a ')' c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 123 16 blur
52 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 125 5 blur
53 IntelliSense: identifier "fp" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 125 12 blur
54 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 126 5 blur
55 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 127 5 blur
56 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 128 5 blur
57 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 130 2 blur
58 IntelliSense: identifier "d_data" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 130 11 blur
59 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 131 2 blur
60 IntelliSense: identifier "d_hp" is undefined c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 131 11 blur
61 IntelliSense: expected a declaration c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 132 5 blur
62 IntelliSense: expected a declaration c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 133 1 blur
63 IntelliSense: expected a declaration c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 158 2 blur
64 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 161 2 blur
65 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 162 2 blur
66 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 164 2 blur
67 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 165 2 blur
68 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 166 2 blur
69 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 168 2 blur
70 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 169 2 blur
71 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 170 2 blur
72 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 172 2 blur
73 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 173 2 blur
74 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 174 2 blur
75 IntelliSense: this declaration has no storage class or type specifier c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 175 2 blur
76 IntelliSense: expected a declaration c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 177 5 blur
77 IntelliSense: expected a declaration c:\Users\Karpińscy\Documents\Visual Studio 2012\Projects\blur\blur\kernel.cu 178 1 blur
最佳答案
您的代码中有不少语法错误。事实上,它们与 CUDA 没有任何关系。也许您应该提高基本的 C 编码技能并了解如何解释编译器错误。
这一行:
cudaMalloc( &d_hp, (sizeof(bitmap_header));
缺少右括号。您看不到这一点,也无法找出表明这一点的编译器错误?
Error 3 error : expected a ")" C:\Users\Karpi˝scy\documents\visual studio 2012\Projects\blur\blur\kernel.cu blur
在cuda中,没有内置变量blockIdy
。也许您的意思是blockIdx.y
?
Error 2 error : identifier "blockIdy" is undefined C:\Users\Karpi˝scy\documents\visual studio 2012\Projects\blur\blur\kernel.cu blur
此行出现另一个编译错误:
cudaMemcpy(d_hp, &hp, (sizeof(bitmap_header), cudaMemcpyHostToDevice);
应该是这样的:
cudaMemcpy(d_hp, &hp, sizeof(bitmap_header), cudaMemcpyHostToDevice);
如果您在修复这些编译错误后仍然需要帮助,请发布一个新问题,其中包含完整但简单的代码,该代码不依赖于从文件中读取图像。只需创建一个简单的测试用例并使用它来验证内核即可。添加我提到的错误检查并使用 cuda-memcheck
运行您的代码。如果你拒绝做这些事情,我就帮不了你。
关于c - 将四个嵌套循环转换为 CUDA 内核,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23712019/
#include using namespace std; class C{ private: int value; public: C(){ value = 0;
这个问题已经有答案了: What is the difference between char a[] = ?string?; and char *p = ?string?;? (8 个回答) 已关闭
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 此帖子已于 8 个月
除了调试之外,是否有任何针对 c、c++ 或 c# 的测试工具,其工作原理类似于将独立函数复制粘贴到某个文本框,然后在其他文本框中输入参数? 最佳答案 也许您会考虑单元测试。我推荐你谷歌测试和谷歌模拟
我想在第二台显示器中移动一个窗口 (HWND)。问题是我尝试了很多方法,例如将分辨率加倍或输入负值,但它永远无法将窗口放在我的第二台显示器上。 关于如何在 C/C++/c# 中执行此操作的任何线索 最
我正在寻找 C/C++/C## 中不同类型 DES 的现有实现。我的运行平台是Windows XP/Vista/7。 我正在尝试编写一个 C# 程序,它将使用 DES 算法进行加密和解密。我需要一些实
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
有没有办法强制将另一个 窗口置于顶部? 不是应用程序的窗口,而是另一个已经在系统上运行的窗口。 (Windows, C/C++/C#) 最佳答案 SetWindowPos(that_window_ha
假设您可以在 C/C++ 或 Csharp 之间做出选择,并且您打算在 Windows 和 Linux 服务器上运行同一服务器的多个实例,那么构建套接字服务器应用程序的最明智选择是什么? 最佳答案 如
你们能告诉我它们之间的区别吗? 顺便问一下,有什么叫C++库或C库的吗? 最佳答案 C++ 标准库 和 C 标准库 是 C++ 和 C 标准定义的库,提供给 C++ 和 C 程序使用。那是那些词的共同
下面的测试代码,我将输出信息放在注释中。我使用的是 gcc 4.8.5 和 Centos 7.2。 #include #include class C { public:
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我的客户将使用名为 annoucement 的结构/类与客户通信。我想我会用 C++ 编写服务器。会有很多不同的类继承annoucement。我的问题是通过网络将这些类发送给客户端 我想也许我应该使用
我在 C# 中有以下函数: public Matrix ConcatDescriptors(IList> descriptors) { int cols = descriptors[0].Co
我有一个项目要编写一个函数来对某些数据执行某些操作。我可以用 C/C++ 编写代码,但我不想与雇主共享该函数的代码。相反,我只想让他有权在他自己的代码中调用该函数。是否可以?我想到了这两种方法 - 在
我使用的是编写糟糕的第 3 方 (C/C++) Api。我从托管代码(C++/CLI)中使用它。有时会出现“访问冲突错误”。这使整个应用程序崩溃。我知道我无法处理这些错误[如果指针访问非法内存位置等,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我有一些 C 代码,将使用 P/Invoke 从 C# 调用。我正在尝试为这个 C 函数定义一个 C# 等效项。 SomeData* DoSomething(); struct SomeData {
这个问题已经有答案了: Why are these constructs using pre and post-increment undefined behavior? (14 个回答) 已关闭 6
我是一名优秀的程序员,十分优秀!