Tag: c

(C中的内联汇编)有趣的内存分段错误

我的asm汇编代码中有以下部分 “LOOP%=:\n\t” “movapd (%%eax), %%xmm4\n\t” “addl $32, %%eax\n\t” “movsd (%%edx), %%xmm5\n\t” “addl $16, %%edx\n\t” “movapd %%xmm4, %%xmm6\n\t” “subl $1, %%ecx\n\t” “unpcklpd %%xmm5, %%xmm5\n\t” “testl %%ecx, %%ecx\n\t” “mulpd %%xmm5, %%xmm6\n\t” “movsd -8(%%edx), %%xmm7\n\t” “addpd %%xmm6, %%xmm0\n\t” “movapd -16(%%eax), %%xmm6\n\t” “unpcklpd %%xmm7, %%xmm7\n\t” “mulpd %%xmm6, %%xmm5\n\t” “addpd %%xmm5, %%xmm1\n\t” “mulpd %%xmm7, %%xmm4\n\t” “addpd %%xmm4, %%xmm2\n\t” “mulpd %%xmm6, […]

关于实际数据序列的FFTW

我正在读一个原始的声音文件,我正试图在它上面运行fft,目的是让PSD结束,但我在开始时遇到一个我无法理解的错误,希望在这里得到一些帮助,代码是: #include #include int main(){ char* fileName = “sound.raw”; FILE* inp = NULL; double* data = NULL; int index = 0; fftw_plan plan; fftw_complex* out; double r,i; int N = 8192; //Allocating the memory for the input data data = (double*) fftw_malloc(sizeof(double)*N); out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*N); plan = fftw_plan_dft_r2c_1d(N,data,out,FFTW_FORWARD); // opening the file for reading […]

从用户模式增加线程量

在Linux内核3.0+上是否可以从用户模式增加线程的量子? 怎么样?

opengl:关于glutMainLoop()的问题

有人可以解释一下glutMainLoop如何工作的吗? 第二个问题,为什么glClearColor(0.0f, 0.0f, 1.0f, 1.0f); 在glutDisplayFunc(RenderScene);之后定义glutDisplayFunc(RenderScene); 首先我们调用glClear(GL_COLOR_BUFFER_BIT); 然后才定义glClearColor(0.0f, 0.0f, 1.0f, 1.0f); int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(800, 00); glutInitWindowPosition(300,50); glutCreateWindow(“GLRect”); glutDisplayFunc(RenderScene); glutReshapeFunc(ChangeSize); glClearColor(0.0f, 0.0f, 1.0f, 1.0f); <– glutMainLoop(); return 0; } void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT); // Set current drawing color to […]

如何在结构数组中获取某些struct成员的地址

我尝试在结构数组中获取某个struct成员的地址,但我不想使用该成员的名称。 它应该是这样的: typedef struct{ unsigned char MrChar; unsigned short MrShort; unsigned long MrLong; unsigned char MrArray[5]; }tModule; static tModule taModulesArray[MODULES_AMOUNT] = { // MODULES_AMOUNT = 2 {0x22, 0x3298, 0x92324583, “djsoe”}, // Module 1 {0x33, 0x1843, 0x65644113, “gskwc”}, // Module 2 }; unsigned long usGetMemberAddr(unsigned long ulModule, unsigned long ulMember){ unsigned long Address; Address = abs(taModulesArray_BaseAddress […]

GCC编译器优化,无法与架构x86_64的主可执行文件“_”链接

*Antonio10ms$ gcc pi.c -o1 pi ld: can’t link with a main executable file ‘pi’ for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 我需要帮助才能对我的.cpp进行优化

冒泡排序中的分段错误

试图编写一个冒泡排序算法,对任何数据类型进行排序,其工作方式类似于C中stdlib中的qsort。 这是我编写的代码,编译它给我一个“分段错误”错误尝试使用-g编译gdb调试,这让错误更多 as: In function `testcmp’: (.text+0x21a): multiple definition of `testcmp’ /tmp/cc9ULHuO.o:new.c:(.text+0x12d): first defined here as: In function `_fini’: (.fini+0x0): multiple definition of `_fini’ /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crti.o(.debug_info): relocation 0 has invalid symbol index 7 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crti.o(.debug_info): relocation 1 has invalid symbol index 8 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crti.o(.debug_info): relocation 2 has invalid symbol index 9 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crti.o(.debug_ranges): relocation 0 […]

有人在C中有一个条件语句的例子吗?

像这样的东西,我想看到完整的语法。 伪代码: var = user_input if var > 5: output = ‘var > 5’ else: output = ‘var < 5'

无法编译读取智能卡的ac应用程序

我正在尝试编译一个示例c应用程序,该应用程序正在使用pkcs#11查找令牌上的所有私钥,并打印其标签和ID,但会出现以下错误 /tmp/ccAqQ7UI.o: In function initialize’: pkcs11_example1.c:(.text+0x8e5): undefined reference to C_Initialize’ /tmp/ccAqQ7UI.o: In function `get_slot’: 这个例子来自这里 使用以下命令进行编译; `gcc pkcs11_example1.c -o slots -L /usr/lib/opensc-pkcs11.so` 我不确定在-L之后我应该链接哪个库。 任何人都可以指导如何编译它,是否有一些库需要链接。

计算c中的数字因子时ac程序的时间限制

我正在解决关于阶乘计算的问题,挑战如下! You are asked to calculate factorials of some small positive integers. Input An integer t, 1<=t<=100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1<=n<=100. Output For each integer n given at input, display a line with the value of n! 我的代码给了我正确的解决方案,但超过了时间限制,即2秒: 代码如下: #include #include #include void […]