由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - Unix下好好的到了linux下segment fault
相关主题
[转载] UNIX下的strtok[转载] 大侠救命哪!!!
What's C++ compliler on Tru64 Unix?alloc memory in UNIX
how to transfer C program run under VC to Unix?where is libstdc++
急问:UNIX (SOLARIS 7。0)中C++ COMPILER命令到底是什么呀?[转载] 老板的程序在unix上运行没问题
在linux 和 Unix 上做 C/C++ 有差别吗?[转载] ask a question.
哪位能推荐适于C/C++ 编程的linux/unix使用手册?Re: How to compare two binary files in Unix?
GCC的编译?where is gcc?
Help: convert // to /* */ in C code?[转载] UNIX下的一个奇怪问题!
相关话题的讨论汇总
话题: unix话题: linux话题: char话题: compaq话题: gcc
进入Unix版参与讨论
1 (共1页)
d*******e
发帖数: 49
1
是在程序返回的时候出错。
会是为啥?
a******e
发帖数: 95
2
use gdb to trace.
it is very common that a program runs correctly in one OS, but not
in another.

【在 d*******e 的大作中提到】
: 是在程序返回的时候出错。
: 会是为啥?

a**n
发帖数: 313
3
without the code, how can others help you? BTW, I am not an expert...
But for example, Linux with gcc deals with string constant differently
with other unix platforms. This is an example which core dumped on Linux
but not on others:
/>cat test.c
#include
#include
#include
int main()
{
char * p = "hello";
*p='p';
printf("%s\n", p);
return 0;
}
/Tru64Unix>cc -V
Compaq C V6.3-025 on Compaq Tru64 UNIX V5.1 (Rev. 732)

【在 d*******e 的大作中提到】
: 是在程序返回的时候出错。
: 会是为啥?

o**v
发帖数: 1662
4
这code是合法但不合理的样子......
各个cc的实现不一样吧.

【在 a**n 的大作中提到】
: without the code, how can others help you? BTW, I am not an expert...
: But for example, Linux with gcc deals with string constant differently
: with other unix platforms. This is an example which core dumped on Linux
: but not on others:
: />cat test.c
: #include
: #include
: #include
: int main()
: {

t*****t
发帖数: 72
5
you may try different compilers, like transfering from gcc
to g++. Sometimes this helps..

【在 d*******e 的大作中提到】
: 是在程序返回的时候出错。
: 会是为啥?

t**c
发帖数: 97
6
why this one does not work for gcc?
or more specifically, if I change char *p to char p[], it works fine.
any particular reason for this?

【在 a**n 的大作中提到】
: without the code, how can others help you? BTW, I am not an expert...
: But for example, Linux with gcc deals with string constant differently
: with other unix platforms. This is an example which core dumped on Linux
: but not on others:
: />cat test.c
: #include
: #include
: #include
: int main()
: {

a**n
发帖数: 313
7
if you define char *p = "hello";
then it mean p pointer to a string literal, which is const, and you are
not supposed to change it. You can refer C++ primer or any other book
for this.
If you define it as char p[], it is a different story.

【在 t**c 的大作中提到】
: why this one does not work for gcc?
: or more specifically, if I change char *p to char p[], it works fine.
: any particular reason for this?

t**c
发帖数: 97
8
that's what I suspect, but just don't know the implementation details.
thanks.

【在 a**n 的大作中提到】
: if you define char *p = "hello";
: then it mean p pointer to a string literal, which is const, and you are
: not supposed to change it. You can refer C++ primer or any other book
: for this.
: If you define it as char p[], it is a different story.

1 (共1页)
进入Unix版参与讨论
相关主题
[转载] UNIX下的一个奇怪问题!在linux 和 Unix 上做 C/C++ 有差别吗?
[转载] 紧急求教一个技术问题 unix c哪位能推荐适于C/C++ 编程的linux/unix使用手册?
compaq engineer 真黑GCC的编译?
Re: 这样的问题还能继续吗?Re: 不是ROOT可以在UNIX下装CXTERM吗?Help: convert // to /* */ in C code?
[转载] UNIX下的strtok[转载] 大侠救命哪!!!
What's C++ compliler on Tru64 Unix?alloc memory in UNIX
how to transfer C program run under VC to Unix?where is libstdc++
急问:UNIX (SOLARIS 7。0)中C++ COMPILER命令到底是什么呀?[转载] 老板的程序在unix上运行没问题
相关话题的讨论汇总
话题: unix话题: linux话题: char话题: compaq话题: gcc