Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cray C编译器不';“我不喜欢”;calloc";_C_Calloc_Cray - Fatal编程技术网

Cray C编译器不';“我不喜欢”;calloc";

Cray C编译器不';“我不喜欢”;calloc";,c,calloc,cray,C,Calloc,Cray,这段非常简单的代码在使用GNU、Intel或PGI(我想它是真正的GNU?)编译时运行良好。在克雷的领导下,它从来没有达到“调试6”;它在“calloc”调用中失败,返回“非法指令”错误。有人看到问题吗?编辑:这是一个运行时错误,不是编译时错误 进一步编辑:如果有人想要其他线索,malloc()在calloc()不起作用的地方起作用 还有另一个编辑:如果你还需要另一条线索,我可以calloc()最多15个字符,没有问题。它失败了16次或更多 #include <stdio.h> #i

这段非常简单的代码在使用GNU、Intel或PGI(我想它是真正的GNU?)编译时运行良好。在克雷的领导下,它从来没有达到“调试6”;它在“calloc”调用中失败,返回“非法指令”错误。有人看到问题吗?编辑:这是一个运行时错误,不是编译时错误

进一步编辑:如果有人想要其他线索,
malloc()
calloc()
不起作用的地方起作用

还有另一个编辑:如果你还需要另一条线索,我可以
calloc()
最多15个字符,没有问题。它失败了16次或更多

#include <stdio.h>
#include <stdlib.h>


int attempt_something() {

   char *needed_file_name = NULL;

   printf("debug2\n");
   needed_file_name = calloc(16, sizeof(char));

   printf("debug6\n");
   fflush(stdout);

   free(needed_file_name);

   return 0;

}



int main() {

   int rst_type;

   printf("debug1\n");
   rst_type = attempt_something();

}
#包括
#包括
int尝试_某物(){
char*needed\u file\u name=NULL;
printf(“debug2\n”);
所需的文件名=calloc(16,sizeof(char));
printf(“debug6\n”);
fflush(stdout);
免费(所需文件名);
返回0;
}
int main(){
int-rst_型;
printf(“debug1\n”);
rst_type=尝试做某事();
}

您确定使用了正确的编译器吗?还是正确的编译器标志?如果你是的话,它可能就坏了。这是常有的事。查看发出的指令并报告错误。编译时失败,或编译正常但在运行时失败?听起来编译器并不完全不喜欢它,这是一个运行时错误。至少试一下malloc()来比较注释。@PaulR“它永远不会到达“debug6”;它在“calloc”调用中失败”-听起来像是运行时。@Daskwuff:C标准保证
sizeof(char)
为1。IIRC,经典的克雷计算机有8位
char
,但是
short
int
long
都占用了64位内存,指向
char
void
的指针与其他指针类型有不同的表示形式。你确定使用了正确的编译器吗?还是正确的编译器标志?如果你是的话,它可能就坏了。这是常有的事。查看发出的指令并报告错误。编译时失败,或编译正常但在运行时失败?听起来编译器并不完全不喜欢它,这是一个运行时错误。至少试一下malloc()来比较注释。@PaulR“它永远不会到达“debug6”;它在“calloc”调用中失败”-听起来像是运行时。@Daskwuff:C标准保证
sizeof(char)
为1。在IIRC中,经典的克雷计算机有8位
char
,但
short
int
long
都占用了64位内存,指向
char
void
的指针与其他指针类型有不同的表示形式。