nrand48源代码看起来很奇怪? [英] nrand48 source code looks weird ?
问题描述
这是来自gnuwin32 libgw32c的nrand48的源代码
long int nrand48(xsubi)unsigned short int xsubi [3];
{
long int result;
(void)__nrand48_r(xsubi,& __ libc_drand48_data,& result);
返回结果;
}
// long int nrand48(xsubi)unsigned short int xsubi [3];
''unsigned short int xsubi [3];''部分意味着''(xsubi)''后面是什么?
来自二进制文件的stdlib.h中的原型是:(由于某种原因stdlib.h
不在源代码发布中?)
extern long int nrand48(unsigned short int __xsubi [3])__ THROW;
所以乍一看我会猜测它与抛出异常有关...但是现在我再看一遍它我认为它是'b $ b'这是xsubi的类型。
原始看起来很奇怪:
1. long int nrand48(xsubi)unsigned short i nt xsubi [3];
这不应该是这样的:
2. long int nrand48(unsigned short int xsubi [3]);
为什么他们把它写成1.?
这只是他们写作的首选方式。 ..还是有一些
的功能?
然后原型再次看起来像2.!?嗯? :)
Euhm ......难道这是一个古怪的程序员的案例吗?呃。
再见,
Skybuck。
Skybuck Flying<否**** @ hotmail.com>写道:这是来自gnuwin32的nrand48的源代码libgw32c
long int nrand48(xsubi)unsigned short int xsubi [3];
{
long int result ;
(void)__nrand48_r(xsubi,& __ libc_drand48_data,& result);
返回结果;
}
// long int nrand48(xsubi)unsigned short int xsubi [3];
''(xsubi)''''unsigned short int xsubi [3];''部分意味着什么?
这是函数定义的旧方式,在没有C标准的情况下,K& R天写回了
。这基本上相当于
借给
long int nrand48(unsigned short int xsubi [3])
在那段时间的代码中你通常有函数定义
开头
my_func(a,b,c)
int a,
char * b,
unsigned short c
{
现在将写成
int my_func(int a,char * b,unsigned short c)
{
来自二进制文件的stdlib.h中的原型是:(由于某种原因,stdlib.h
不在源代码分发中?)
extern long int nrand48(unsigned short int __xsubi [3])__ THROW;
乍一看,我猜它与抛出异常有关......但是现在我再次看它,我认为它是xsubi的类型。
最好不要看头文件,除非你有很好的理由
(或只是出于好奇)。很多系统依赖的魔法在那里上$
。
问候,Jens
-
\ Jens Thoms Toerring ___ Je***********@physik.fu- berlin.de
\ __________________________ http:// www。 toerring.de
< Je *********** @ physik.fu-berlin &由Matchi.com提供回到GT;在消息中写道
新闻:2l ************ @ uni-berlin.de ...Skybuck Flying< no ** **@hotmail.com>写道:这是来自gnuwin32 libgw32c的nrand48的源代码
long int nrand48(xsubi)unsigned short int xsubi [3];
{
long int result;
(void)__nrand48_r(xsubi,& __ libc_drand48_data,& result);< br>
返回结果;
}
// long int nrand48(xsubi)unsigned short int xsubi [3] ;
''unsigned short int xsubi [3];''部分意味着''(xsubi)''后面是什么?
这是功能定义的旧方式,在没有C标准的K& R天中写回。这基本等同于
long int nrand48(unsigned short int xsubi [3])
在从那时起你的典型代码中有函数定义
my_func(a,b,c)
int a,
char * b,
unsigned short c
{
现在将写成
int my_func(int a,char * b,unsigned short c)
{>
是的,我开始认为C真的是#^#@
语言:)
Visual C / C ++ 6.0并不支持旧方式...
<<< ---叹气--->>>
所以现在我必须重新写一遍...
幸运的是我...它只是一点点代码......幸运的是我
很少在C中编程:P = D
Thx的描述......大声笑......它必须是痛苦的C代码:D
再见,
Skybuck。
This is the source code for nrand48 from gnuwin32 libgw32c
long int nrand48 (xsubi) unsigned short int xsubi[3];
{
long int result;
(void) __nrand48_r (xsubi, &__libc_drand48_data, &result);
return result;
}
// long int nrand48 (xsubi) unsigned short int xsubi[3];
What does the ''unsigned short int xsubi[3];'' part mean after ''(xsubi)'' ?
The prototype in stdlib.h from the binaries is: (for some reason stdlib.h
was not in source distribution ?)
extern long int nrand48 (unsigned short int __xsubi[3]) __THROW;
So at first sight I would guess it has to do with throwing exceptions... but
now that I look at it again it I think it''s the type for xsubi.
The original looks really weird:
1. long int nrand48 (xsubi) unsigned short int xsubi[3];
Isn''t that supposed to look like this:
2. long int nrand48 (unsigned short int xsubi[3] );
Why did they write it as 1. ?
Is that just their preferred way of writing it down... or does it have some
sort of functionality ?
The prototype then again looks like 2. !? huh ?! :)
Euhm... Could this be a case of wacky c programmers ? eh.
Bye,
Skybuck.
Skybuck Flying <no****@hotmail.com> wrote:This is the source code for nrand48 from gnuwin32 libgw32c long int nrand48 (xsubi) unsigned short int xsubi[3];
{
long int result; (void) __nrand48_r (xsubi, &__libc_drand48_data, &result); return result;
} // long int nrand48 (xsubi) unsigned short int xsubi[3]; What does the ''unsigned short int xsubi[3];'' part mean after ''(xsubi)'' ?
That''s the very old way function definitions where written back in
the K&R days when there wasn''t a C standard. It''s basically equiva-
lent to
long int nrand48( unsigned short int xsubi[ 3 ] )
In code dating back from that time you typically had function definitions
starting with
my_func( a, b, c )
int a,
char *b,
unsigned short c
{
which nowadays would be written as
int my_func( int a, char *b, unsigned short c )
{
The prototype in stdlib.h from the binaries is: (for some reason stdlib.h
was not in source distribution ?) extern long int nrand48 (unsigned short int __xsubi[3]) __THROW; So at first sight I would guess it has to do with throwing exceptions... but
now that I look at it again it I think it''s the type for xsubi.
Better don''t look at the header files unless you have very good reasons
to (or just out of curiosity). Lots of system-dependend magic is going
on there.
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
<Je***********@physik.fu-berlin.de> wrote in message
news:2l************@uni-berlin.de...Skybuck Flying <no****@hotmail.com> wrote:This is the source code for nrand48 from gnuwin32 libgw32c
long int nrand48 (xsubi) unsigned short int xsubi[3];
{
long int result;
(void) __nrand48_r (xsubi, &__libc_drand48_data, &result);
return result;
}
// long int nrand48 (xsubi) unsigned short int xsubi[3];
What does the ''unsigned short int xsubi[3];'' part mean after ''(xsubi)'' ?
That''s the very old way function definitions where written back in
the K&R days when there wasn''t a C standard. It''s basically equiva-
lent to
long int nrand48( unsigned short int xsubi[ 3 ] )
In code dating back from that time you typically had function definitions
starting with
my_func( a, b, c )
int a,
char *b,
unsigned short c
{
which nowadays would be written as
int my_func( int a, char *b, unsigned short c )
{
Yes, I was starting to think that C was a really #^#@
language :)
Visual C/C++ 6.0 doesn''t the support the old way...
<<<--- sigh --->>>
So now I have to re-write it all...
Fortunately for me... It''s only a little bit of code... and fortunately I
rarely program in C :P =D
Thx for the description... Lol... it must be painfull to code in C :D
Bye,
Skybuck.
这篇关于nrand48源代码看起来很奇怪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!