473,665 Members | 2,774 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 13032
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_Keit h) 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...@yah oo.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...@yah oo.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....@gm ail.comwrote:
user923005 wrote:
On Jul 6, 6:54�pm, CBFalconer <cbfalco...@yah oo.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>gre pcarl frand *.h

c:\dannfast\Dev-Cpp\include>

None in mingw:
c:\dcorbit64\mi ngw\include>gre pcarl frand *.h

c:\dcorbit64\mi ngw\include>

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

c:\dannfast\Bor land\BCC55\Incl ude>

None in Watcom:
c:\dannfast\e_d rive\watcom\h>g repcarl frand *.h

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

c:\dannfast\e_d rive\watcom\qh>

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

c:\dannfast\e_d rive\dm\include >

None in uClibc
c:\dannfast\e_d rive\uClibc\inc lude>grepcarl frand *.h

c:\dannfast\e_d rive\uClibc\inc lude>

None in Bloodshed:
c:\dannfast\e_d rive\bloodshed\ include>grepcar l frand *.h

c:\dannfast\e_d rive\bloodshed\ include>

None in Visual C++ 6.0:
c:\dannfast\lan g\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\lan g\VC98\Include>

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

c:\dcorbit64\Pr ogram Files\Microsoft Visual Studio\VC98\Inc lude>

None in Visual Studio.Net:
c:\dannfast\Pro gram Files\Microsoft Visual Studio .NET
\Vc7\include>gr epcarl frand *.h

c:\dannfast\Pro gram Files\Microsoft Visual Studio .NET\Vc7\includ e>

None in Visual Studio.Net 2003:
c:\dannfast\Pro gram Files\Microsoft Visual Studio .NET
2003\Vc7\includ e>grepcarl frand *.h

c:\dannfast\Pro gram Files\Microsoft Visual Studio .NET
2003\Vc7\includ e>

None in VC++ 8:
c:\dannfast\Pro gram Files\Microsoft Visual Studio 8\VC
\include>grepca rl frand *.h

c:\dannfast\Pro gram 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_d rive\clib\compi ler>grepcarl frand *.h

c:\dannfast\e_d rive\clib\compi ler>

None in SAS/C:
c:\dannfast\Pro gram Files\SAS Institute\SASC7 01\include>grep carl frand
*.h

c:\dannfast\Pro gram Files\SAS Institute\SASC7 01\include>

None in Cint:
c:\dannfast\e_d rive\root\cint\ include>grepcar l frand *.h

c:\dannfast\e_d rive\root\cint\ include>

None in Tendra:
c:\dannfast\e_d rive\tendra-20041231\src\li b\apis\ansi>gre pcarl frand
*.h

c:\dannfast\e_d rive\tendra-20041231\src\li b\apis\ansi>

Looks like LCC:
c:\dcorbit64\lc c\include>grepc arl 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....@gm ail.comwrote:
>user923005 wrote:
On Jul 6, 6:54?pm, CBFalconer <cbfalco...@yah oo.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

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

Similar topics

3
5358
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 they approach 1.6 to 1.7 GB of RAM. Is the rest of the memory space between 1.7 GB and 2 GB is taken up by the runtime? 300mb? That cannot be since I've seen winform apps run (not fast, but still) on systems with 128mb. And if you set your...
6
1273
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 a calculation involving three values all stored in Access as Single. This is how the values bubble up: Bottom query
0
1276
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
1919
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 can think of to the list you are asking for. On the other hand, what's wrong with constructing the list as you did in your example above?
0
1442
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 keyword module will help me Thanks again Ohad Frand
0
1916
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
3311
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
8863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8779
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5660
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1761
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.