473,508 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

frand

When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).

Is it legal if I use "frand" in a source file if stlib.h is not
included there?
Jul 6 '08 #1
10 12993
void main <no****@nospam.invalidwrites:
When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).

Is it legal if I use "frand" in a source file if stlib.h is not
included there?
Yes.

There is no standard C function called "frand". (There are functions
"rand" and "srand").

If a compiler, invoked in conforming mode, complains about you
defining a function called "frand", that's a flaw in the compiler.
I suggest you submit a bug report.

If you're invoking the compiler in non-conforming mode, then you
probably have no grounds for complaint, though you're free to complain
anyway.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 6 '08 #2
void main <no****@nospam.invalidwrites:
When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).

Is it legal if I use "frand" in a source file if stlib.h is not
included there?
Yes.

Something tells me I am supposed to add that you can use frand even
when you do include stdlib.h, but I suspect you know that. If you
*don't* know that, get a copy of the C standard[1]. It tells you what
identifiers are reserved and where, if at all, they are declared or
defined.

[1] For example, a draft is available at:
http://www.open-std.org/jtc1/sc22/wg...docs/n1256.pdf

--
Ben.
Jul 6 '08 #3
Keith Thompson wrote:
void main <no****@nospam.invalidwrites:
>When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).

Is it legal if I use "frand" in a source file if stlib.h is not
included there?

Yes.

There is no standard C function called "frand". (There are functions
"rand" and "srand").

If a compiler, invoked in conforming mode, complains about you
defining a function called "frand", that's a flaw in the compiler.
I suggest you submit a bug report.

If you're invoking the compiler in non-conforming mode, then you
probably have no grounds for complaint, though you're free to complain
anyway.
Thanks but I need a really portable solution. I solved it like this

#define frand xyz
#include <stdlib.h>
#undef frand

Is that good practice?

Jul 7 '08 #4
void main wrote:
Keith Thompson wrote:
>void main <no****@nospam.invalidwrites:
>>When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).

Is it legal if I use "frand" in a source file if stlib.h is not
included there?

Yes.

There is no standard C function called "frand". (There are
functions "rand" and "srand").

If a compiler, invoked in conforming mode, complains about you
defining a function called "frand", that's a flaw in the compiler.
I suggest you submit a bug report.

If you're invoking the compiler in non-conforming mode, then you
probably have no grounds for complaint, though you're free to
complain anyway.

Thanks but I need a really portable solution. I solved it like this

#define frand xyz
#include <stdlib.h>
#undef frand

Is that good practice?
No. If the compiler writer has ignored the standard, you have no
idea why and what is affected. A better temporary step is to
replace *your* use of frand by something else. And you should make
loud and insistent bug reports to the compiler marketer and insist
the bug be fixed.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Jul 7 '08 #5
On Jul 6, 6:54*pm, CBFalconer <cbfalco...@yahoo.comwrote:
void main wrote:
Keith Thompson wrote:
void main <nos...@nospam.invalidwrites:
>When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).
>Is it legal if I use "frand" in a source file if stlib.h is not
included there?
Yes.
There is no standard C function called "frand". *(There are
functions "rand" and "srand").
If a compiler, invoked in conforming mode, complains about you
defining a function called "frand", that's a flaw in the compiler.
I suggest you submit a bug report.
If you're invoking the compiler in non-conforming mode, then you
probably have no grounds for complaint, though you're free to
complain anyway.
Thanks but I need a really portable solution. I solved it like this
#define frand xyz
#include <stdlib.h>
#undef frand
Is that good practice?

No. *If the compiler writer has ignored the standard, you have no
idea why and what is affected. *A better temporary step is to
replace *your* use of frand by something else. *And you should make
loud and insistent bug reports to the compiler marketer and insist
the bug be fixed.
There is no frand() in any of the Microsoft standard headers. E.g.:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include>c:\utils
\grep.exe frand *.h

C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include>

The fact that his name is "void main" just might possibly be a clue
that this is a troll.
Jul 8 '08 #6
user923005 wrote:
On Jul 6, 6:54*pm, CBFalconer <cbfalco...@yahoo.comwrote:
>void main wrote:
Keith Thompson wrote:
void main <nos...@nospam.invalidwrites:
>>When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).
>>Is it legal if I use "frand" in a source file if stlib.h is not
included there?
>Yes.
>There is no standard C function called "frand". *(There are
functions "rand" and "srand").
>If a compiler, invoked in conforming mode, complains about you
defining a function called "frand", that's a flaw in the compiler.
I suggest you submit a bug report.
>If you're invoking the compiler in non-conforming mode, then you
probably have no grounds for complaint, though you're free to
complain anyway.
Thanks but I need a really portable solution. I solved it like this
#define frand xyz
#include <stdlib.h>
#undef frand
Is that good practice?

No. *If the compiler writer has ignored the standard, you have no
idea why and what is affected. *A better temporary step is to
replace *your* use of frand by something else. *And you should make
loud and insistent bug reports to the compiler marketer and insist
the bug be fixed.

There is no frand() in any of the Microsoft standard headers. E.g.:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include>c:\utils
\grep.exe frand *.h

C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include>

The fact that his name is "void main" just might possibly be a clue
that this is a troll.
Regardless of whether he is a troll his post is, as far as I can tell,
quite genuine. The identifier 'frand' *is* defined by a compiler in
stdlib.h, even under switches for disallowing all language extensions
and supposedly conforming to ANSI C.

I will not name the compiler in question, since it may be obvious to
more than a few already.

Jul 8 '08 #7
On Jul 7, 6:06Â*pm, santosh <santosh....@gmail.comwrote:
user923005 wrote:
On Jul 6, 6:54�pm, CBFalconer <cbfalco...@yahoo.comwrote:
void main wrote:
Keith Thompson wrote:
void main <nos...@nospam.invalidwrites:
>When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).
>Is it legal if I use "frand" in a source file if stlib.h is not
included there?
Yes.
There is no standard C function called "frand". �(There are
functions "rand" and "srand").
If a compiler, invoked in conforming mode, complains about you
defining a function called "frand", that's a flaw in the compiler.
I suggest you submit a bug report.
If you're invoking the compiler in non-conforming mode, then you
probably have no grounds for complaint, though you're free to
complain anyway.
Thanks but I need a really portable solution. I solved it like this
#define frand xyz
#include <stdlib.h>
#undef frand
Is that good practice?
No. �If the compiler writer has ignored the standard, you haveno
idea why and what is affected. �A better temporary step is to
replace *your* use of frand by something else. �And you shouldmake
loud and insistent bug reports to the compiler marketer and insist
the bug be fixed.
There is no frand() in any of the Microsoft standard headers. Â*E.g..:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include>c:\utils
\grep.exe frand *.h
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include>
The fact that his name is "void main" just might possibly be a clue
that this is a troll.

Regardless of whether he is a troll his post is, as far as I can tell,
quite genuine. The identifier 'frand' *is* defined by a compiler in
stdlib.h, even under switches for disallowing all language extensions
and supposedly conforming to ANSI C.

I will not name the compiler in question, since it may be obvious to
more than a few already.
You certainly got me curious:
None in dev-cpp:
c:\dannfast\Dev-Cpp\include>grepcarl frand *.h

c:\dannfast\Dev-Cpp\include>

None in mingw:
c:\dcorbit64\mingw\include>grepcarl frand *.h

c:\dcorbit64\mingw\include>

None in Borland:
c:\dannfast\Borland\BCC55\Include>grepcarl frand *.h
sqlfront.h ( 586): #define SQLCRSFRAND 10088
wininet.h ( 3128): IN BOOL fRandomRead,
wininet.h ( 3138): IN BOOL fRandomRead,

c:\dannfast\Borland\BCC55\Include>

None in Watcom:
c:\dannfast\e_drive\watcom\h>grepcarl frand *.h

c:\dannfast\e_drive\watcom\h>
c:\dannfast\e_drive\watcom\qh>grepcarl frand *.h

c:\dannfast\e_drive\watcom\qh>

None in Digital Mars:
c:\dannfast\e_drive\dm\include>grepcarl frand *.h

c:\dannfast\e_drive\dm\include>

None in uClibc
c:\dannfast\e_drive\uClibc\include>grepcarl frand *.h

c:\dannfast\e_drive\uClibc\include>

None in Bloodshed:
c:\dannfast\e_drive\bloodshed\include>grepcarl frand *.h

c:\dannfast\e_drive\bloodshed\include>

None in Visual C++ 6.0:
c:\dannfast\lang\VC98\Include>grepcarl frand *.h
SQLFRONT.H ( 579): #define SQLCRSFRAND 10088
WININET.H ( 2696): IN BOOL fRandomRead,
WININET.H ( 2706): IN BOOL fRandomRead,

c:\dannfast\lang\VC98\Include>

None in VC++ 98:
c:\dcorbit64\Program Files\Microsoft Visual Studio
\VC98\Include>grepcarl frand *.h
SQLFRONT.H ( 579): #define SQLCRSFRAND 10088
WININET.H ( 2696): IN BOOL fRandomRead,
WININET.H ( 2706): IN BOOL fRandomRead,

c:\dcorbit64\Program Files\Microsoft Visual Studio\VC98\Include>

None in Visual Studio.Net:
c:\dannfast\Program Files\Microsoft Visual Studio .NET
\Vc7\include>grepcarl frand *.h

c:\dannfast\Program Files\Microsoft Visual Studio .NET\Vc7\include>

None in Visual Studio.Net 2003:
c:\dannfast\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include>grepcarl frand *.h

c:\dannfast\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include>

None in VC++ 8:
c:\dannfast\Program Files\Microsoft Visual Studio 8\VC
\include>grepcarl frand *.h

c:\dannfast\Program Files\Microsoft Visual Studio 8\VC\include>

None in VC++ 9:
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include>grepcarl
frand *.h

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include>

None in Clib:
c:\dannfast\e_drive\clib\compiler>grepcarl frand *.h

c:\dannfast\e_drive\clib\compiler>

None in SAS/C:
c:\dannfast\Program Files\SAS Institute\SASC701\include>grepcarl frand
*.h

c:\dannfast\Program Files\SAS Institute\SASC701\include>

None in Cint:
c:\dannfast\e_drive\root\cint\include>grepcarl frand *.h

c:\dannfast\e_drive\root\cint\include>

None in Tendra:
c:\dannfast\e_drive\tendra-20041231\src\lib\apis\ansi>grepcarl frand
*.h

c:\dannfast\e_drive\tendra-20041231\src\lib\apis\ansi>

Looks like LCC:
c:\dcorbit64\lcc\include>grepcarl frand *.h
stdlib.h ( 77): double frand(void);
wininet.h ( 1780): BOOL fRandomRead,
wininet.h ( 1787): BOOL fRandomRead,
xlcall.h ( 173): #define xlfRand 63

Suggestion to Jacob:
#ifndef __ANSIC__ONLY__
double frand(void);
#endif
Jul 9 '08 #8
user923005 wrote:
On Jul 7, 6:06*pm, santosh <santosh....@gmail.comwrote:
>user923005 wrote:
On Jul 6, 6:54?pm, CBFalconer <cbfalco...@yahoo.comwrote:
void main wrote:
Keith Thompson wrote:
void main <nos...@nospam.invalidwrites:
>>When porting a program to MS-Windows I got a redefinition error
on "frand" (already defined in stdlib.h).
>>Is it legal if I use "frand" in a source file if stlib.h is not
included there?
>Yes.
>There is no standard C function called "frand". ?(There are
functions "rand" and "srand").
>If a compiler, invoked in conforming mode, complains about you
defining a function called "frand", that's a flaw in the compiler.
I suggest you submit a bug report.
>If you're invoking the compiler in non-conforming mode, then you
probably have no grounds for complaint, though you're free to
complain anyway.
Thanks but I need a really portable solution. I solved it like this
#define frand xyz
#include <stdlib.h>
#undef frand
Is that good practice?
>No. ?If the compiler writer has ignored the standard, you have no
idea why and what is affected. ?A better temporary step is to
replace *your* use of frand by something else. ?And you should make
loud and insistent bug reports to the compiler marketer and insist
the bug be fixed.
There is no frand() in any of the Microsoft standard headers. *E.g.:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include>c:\utils
\grep.exe frand *.h
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include>
The fact that his name is "void main" just might possibly be a clue
that this is a troll.

Regardless of whether he is a troll his post is, as far as I can tell,
quite genuine. The identifier 'frand' *is* defined by a compiler in
stdlib.h, even under switches for disallowing all language extensions
and supposedly conforming to ANSI C.

I will not name the compiler in question, since it may be obvious to
more than a few already.
[...]
Suggestion to Jacob:
#ifndef __ANSIC__ONLY__
double frand(void);
#endif
(my name isn't Jacob, but) I assume this should go into the compiler's
stdlib.h? Is it really a good idea if I change compiler internal files?

Jul 9 '08 #9
On Wed, 9 Jul 2008 23:49:20 +0200 (CEST), void main
<no****@nospam.invalidwrote:
>user923005 wrote:
snip
>Suggestion to Jacob:
#ifndef __ANSIC__ONLY__
double frand(void);
#endif

(my name isn't Jacob, but) I assume this should go into the compiler's
stdlib.h? Is it really a good idea if I change compiler internal files?
Somewhere between terrible and catastrophic!

As a general rule, you should only change a product's files where the
implementation/installation instructions specify. If you make the
suggested change in stdlib.h and you later get an update, your change
will be lost and you will be confused why unchanged programs that used
to compile no longer do.
Remove del for email
Jul 10 '08 #10
"void main" <no****@nospam.invalidwrote in message
news:82****************@aioe.org...
[snip]
[...]
>Suggestion to Jacob:
#ifndef __ANSIC__ONLY__
double frand(void);
#endif

(my name isn't Jacob, but) I assume this should go into the compiler's
stdlib.h? Is it really a good idea if I change compiler internal files?
Jacob is the name of the compiler vendor and a frequent poster here.

If you want to use LCC, your solution for now is to never use frand() for
your own function name until it gets repaired.
** Posted from http://www.teranews.com **
Jul 10 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5349
by: Frank Rizzo | last post by:
It is common knowledge that 32-bit processes can use up to 2GB of RAM. This has been my experience with native (vb6, c++) apps. However, .NET apps tend to crash with Out of Memory errors whenever...
6
1271
by: Torben Frandsen | last post by:
Hi I'm porting an old Access/VB application to .Net, and I've encountered a small problem. The VB application takes a value from a query and stores it in a Double. This value is the result of...
0
1272
by: Tim Golden | last post by:
Ohad Frand wrote: You can do this with WMI under Windows: <code> import wmi c = wmi.WMI () for i in c.Win32_LogicalDisk (): print i.Caption
0
1902
by: Gary Herron | last post by:
Ohad Frand wrote: There is no way you can consider 'elif', 'else', 'except', and 'from' statements. However, as someone pointed out, the kwlist from the keyword module is the closest thing we...
0
1434
by: Ohad Frand | last post by:
Hi Thanks a lot for your reply I think the main uses for it is to study the language and to see that I didn't miss anything else or that something is changed from one version to another. The...
0
1890
by: Laszlo Nagy | last post by:
ohad frand wrote: So this is what you have: /1/tmp1.py /1/tmp2.py /2/tmp1.py /2/tmp2.py
87
3249
by: rufus | last post by:
Is there a C-compiler (and for that matter C++ compiler) for windows that can be run from the commmand line?
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.