Tag: 编译器错误

架构x86_64的未定义符号在C中的含义是什么?

这是我的代码。 #include int main(){ int first; int second; int third; float average=0.0; printf (“This program will find the average of 3 numbers.\n”); delay(1000); printf (“Type the first number.\n”); scanf (“%d”, &first); printf (“Type the second number.\n”); scanf (“%d”, &second); printf (“Type the third number.\n”); scanf (“%d”, &third); average = (first+second+third)/2.0; printf (“The average of %d, […]

我该如何编译这个C代码?

我下载了这个源代码(.zip),并希望在我的Mac(OSX 10.11.2)上使用XCode版本7.2(7C68)进行编译。 我开始编译文件fdist.c gcc -o fdist2 -O fdist.c -lm 但它会返回一系列警告和错误(见下文)。 看看文件,我看到它确实看起来不像我习惯的那种代码。 通常,似乎未指定函数返回的对象类型。 README_fdist2没有多大帮助。 有关如何编译代码的指南,但第一行中有一个拼写错误。 我该如何编译这段代码? 以下是命令gcc -o fdist2 -O fdist.c -lm返回的错误和警告 fdist2.c:42:1: warning: type specifier missing, defaults to ‘int’ [-Wimplicit-int] main() ^ fdist2.c:117:3: warning: implicit declaration of function ‘sim1’ is invalid in C99 [-Wimplicit-function-declaration] sim1(init,initot,rm,mu,freq_arr,val_arr,&noall); ^ fdist2.c:119:4: warning: implicit declaration of function ‘my_thetacal’ is invalid […]

在二维数组函数中返回数组?

我想使用函数返回二维数组的平均值与不同的数组,程序运行正常,但它返回一个大的负数,我如何返回数组或应用指针到我的函数? 我在哪里添加指针使其工作? 我遇到这个: 警告:传递’returnAvg’的参数1使得整数指针没有强制转换[默认情况下启用] | #include #include #include void returnAvg(int allTest[2][2],int students,int test); int main () { int students = 2, test = 2, i,j; int allTest[students][test]; for(i=0;i<students;i++){ for(j=0;j “,i+1,j+1); scanf(“%d”,&allTest[i][j]); } } returnAvg(allTest[2][2],students,test); return 0; } void returnAvg(int allTest[2][2],int students,int test){ int i,j; int avg[students]; for(i=0;i<students;i++){ int sum = 0; for(j=0;j<test;j++){ sum += (allTest[i][j]); […]

在没有优化的程序上使用VS2013进行调试,但当前上下文中仍然没有局部变量的符号

我正在尝试调试Python2.7以了解有关python如何工作的更多信息。 当我尝试在第4399行调试ceval.c时,我注意到我无法在IDE中看到arg值, 我检查了优化被禁用并且/ DEBUG选项已打开。 我看了反汇编,我确实看到arg有一个值,代码被执行了。 我尝试在VS2013和VS2017中进行调试,两者都是相同的甚至PDB加载 我使用dv命令尝试使用WinDbg,它仍然无法看到任何局部变量 我的编译命令是: /GS /analyze- /W3 /Gy /Zc:wchar_t /I”H:\project\cpython-2.7\Include” /I”H:\project\cpython-2.7\PC” /Zi /Gm- /Od /Fd”H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\vc120.pdb” /fp:precise /D “_CONSOLE” /D “WIN32” /D “_WIN32” /D “_DEBUG” /D “_MBCS” /errorReport:prompt /GF /WX- /Zc:forScope /Gd /Oy- /MDd /Fa”H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\” /nologo /Fo”H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\” /Fp”H:\project\cpython-2.7\PCbuild\obj\win32_Debug\python\python_d.pch” 我的链接命令是: /OUT:”H:\project\cpython-2.7\PCBuild\python_d.exe” /MANIFEST:NO /NXCOMPAT /PDB:”H:\project\cpython-2.7\PCBuild\python_d.pdb” /DYNAMICBASE “kernel32.lib” “user32.lib” “gdi32.lib” “winspool.lib” “comdlg32.lib” “advapi32.lib” “shell32.lib” “ole32.lib” […]

在ac程序中表达式是否太长可以编译gcc?

假设我将一个非常长的等式输入到一行c代码(.c或.h文件)中,该代码长度为数千(可能是数万)个字符; 例如 y = (2*(36*pow(x,2)*pow(A[n][j],5)*B[n][j] + (several thousand more such expressions) ) ; (这里只是将x作为变量,A,B作为双指针等)。 在gcc编译器无法正确编译代码之前,是否有一行代码在.c或.h文件中有多长时间? 我已经为#c阅读了几个关于这个问题的相关讨论,但不仅仅是简单的c。 我从来没有从gcc中收到任何关于我的代码中包含太长行的错误,但我想更加确定这一点。 编辑:在回应下面的一些评论时,我现在意识到我问了两个(我认为密切相关的)问题: (1)在gcc编译器可能发生错误/引发错误之前,行中c可以有多长时间有限制吗? (2)在gcc编译器可能发生错误/引发错误之前,表达式的复杂程度是否有限制? (例如,我们可以将很长的一行分成几行,但它们都是同一个表达式的一部分)。

架构x86_64的未定义符号:(Mac OS X 10.7)

我正在为我的CS课程学习MP。 我们的计算机实验室正在Linux OS下工作,但我尝试在家用计算机上编译代码(Mac OS X)。 我收到以下错误: Undefined symbols for architecture x86_64: “_tdestroy”, referenced from: _dictionary_destroy in libdictionary.o _dictionary_destroy_free in libdictionary.o ld: symbol(s) not found for architecture x86_64 我尝试在网上找到解决方案,但我没有成功。 我们在Makefile中使用以下宏: CC = gcc INC = -I. FLAGS = -g -W -Wall LIBS = -lpthread 有任何想法吗?

函数声明不是C中的原型

我正在学习为初学者编写Linux内核模块。 我要做的是使用DFS算法将每个任务及其子进程写入内核日志。 但是当我使用Makefile编译代码时,它显示上面的错误: function declaration isn’t a prototype [-Werror=strict-prototypes] struct task_struct *current; 它在函数DFS中指出task_struct关键字。 这是我的代码: # include # include # include # include # include void DFS (struct task_struct *task) { struct task_struct *current; struct list_head *list; list_for_each (list, &task->children) { current = list_entry(list, struct task_struct, sibling); printk(KERN_INFO “%d\t%d\t%s \n”, (int)current->state, current->pid, current->comm); if (current != […]

为什么三字母在现代C ++编译器中会产生错误?

即使在GCC编译器中,如果没有明确指定trigraph属性,也不会编译三字符。 #include int main() { int a=4; if((a==4) ??! (a==5)) printf(“\nHello world!”); return 0; } 保存为try.c的程序仅在我们指定gcc -Wall -trigraphs try.c时才在GCC编译器中编译,它仍然显示警告。 你可以招募一些能够处理和处理三字符而没有任何错误或警告的编译器吗?

minixml未定义对`mxmlNewXML’的引用

我在将minixml库拉入项目时遇到问题。 我按照minixml页面上的文档http://www.minixml.org/documentation.php/install.html进行了操作 安装时没有错误,我看到/usr/local/include/mxml.h中的.h文件和/usr/local/lib/libmxml.a中的汇编文件 我已经使用#define包含mxml.h并且发现该文件没有问题(因为mxml_node_t等迷你xml类型没有错误… 我也一直用-lmxml编译标志来编译链接库。 gcc -lpthread -lmxml -o…and so forth undefined reference to `mxmlNewXML’ 这是我如何调用与原型匹配的函数: mxmlNewXML(“blah”);

适当的字符串内存分配

所以我遇到了这个问题,我现在已经试着解决了大约8个小时……我已经放弃了寻求答案而没有帮助。 我已经尝试分别使用realloc()和malloc() ,所以任何输入都会很棒! 这个在C中的目的是允许创建一个’map’,我稍后将使用ncurses来创建地图。 文件的输入如下 10X16 de4 dw9 ds8 g8,7 m3,4 h6,5 p2,2 6X20 dn5 ds4 W4,3 e2,12 M1,1 10X13 ds3 dw9 10X12 5X4 6×12 这是代码: char *importLevel() { FILE *fPointer; fPointer = fopen(“Level”, “r”); //Opens text file to read char* rooms[150];// set up for memory allocation char commands[150];// set up for pulling data from […]