473,902 Members | 4,667 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RFC: clc-compliant pseudo-random number generator

One issue that comes up fairly often around here is the poor
quality of the pseudo-random number generators supplied with many
C implementations . As a result, we have to recommend things like
using the high-order bits returned by rand() instead of the
low-order bits, avoiding using rand() for anything that wants
decently random numbers, not using rand() if you want more than
approx. UINT_MAX total different sequences, and so on.

So I wrote some PRNG code that uses RC4, with a seed of up to 256
bytes. Here it is. I believe it is clc-compliant. Comments on
this and anything else are welcome.

----------------------------------------------------------------------
/*
* prng.c - Portable, ISO C90 and C99 compliant high-quality
* pseudo-random number generator based on the alleged RC4
* cipher. This PRNG should be suitable for most general-purpose
* uses. Not recommended for cryptographic or financial
* purposes. Not thread-safe.
*/

/*
* Copyright (c) 2004 Ben Pfaff <bl*@cs.stanfor d.edu>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. The author's and contributors' names may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
*/

#include "prng.h"
#include <assert.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <time.h>

/* RC4-based pseudo-random state. */
static unsigned char s[256];
static int s_i, s_j;

/* Nonzero if PRNG has been seeded. */
static int seeded;

/* Take advantage of inlining if possible. */
#if __STDC_VERSION_ _ >= 199901L
#define INLINE inline
#else
#define INLINE
#endif

/* Swap bytes. */
static INLINE void
swap_byte (unsigned char *a, unsigned char *b)
{
unsigned char t = *a;
*a = *b;
*b = t;
}

/* If KEY is non-null and SIZE is nonzero, seeds the
pseudo-random number generator based on the SIZE bytes in BUF.
At most the first 256 bytes of BUF are used. If KEY is a null
pointer and SIZE is zero, seeds the pseudo-random number
generator based on the current time.

If this function is not called by the user before any prng_get
function, it is called automatically to obtain a time-based
seed. */
void
prng_seed (const void *key_, size_t size)
{
const unsigned char *key = key_;
size_t key_idx;
int i, j;

assert ((key != NULL && size > 0) || (key == NULL && size == 0));

if (key == NULL)
{
static time_t t;

t = (t == 0) ? time (NULL) : t + 1;
key = (void *) &t;
size = sizeof t;
}

for (i = 0; i < 256; i++)
s[i] = i;
for (key_idx = 0, i = j = 0; i < 256; i++)
{
j = (j + s[i] + key[key_idx]) & 255;
swap_byte (s + i, s + j);
if (++key_idx >= size)
key_idx = 0;
}

s_i = s_j = 0;
seeded = 1;
}

/* Returns a pseudo-random integer in the range [0,255]. */
unsigned char
prng_get_octet (void)
{
if (!seeded)
prng_seed (NULL, 0);

s_i = (s_i + 1) & 255;
s_j = (s_j + s[s_i]) & 255;
swap_byte (s + s_i, s + s_j);

return s[(s[s_i] + s[s_j]) & 255];
}

/* Returns a pseudo-random integer in the range [0,UCHAR_MAX]. */
unsigned char
prng_get_byte (void)
{
if (UCHAR_MAX == 255)
{
/* Normal case for 8-bit bytes. */
return prng_get_octet ();
}
else
{
/* Handle oversize bytes. */
unsigned byte = prng_get_octet ();
unsigned done = 255;
while ((unsigned char) done != UCHAR_MAX)
{
byte = (byte << 8) | prng_get_octet ();
done = (done << 8) | 255;
}
return byte;
}
}

/* Fills BUF with SIZE pseudo-random bytes. */
void
prng_get_bytes (void *buf_, size_t size)
{
unsigned char *buf;

for (buf = buf_; size-- > 0; buf++)
*buf = prng_get_byte ();
}

/* Returns a pseudo-random unsigned long in the range [0,
ULONG_MAX]. */
unsigned long
prng_get_ulong (void)
{
unsigned long ulng = prng_get_octet ();
unsigned long done = 255;

while (done != ULONG_MAX)
{
ulng = (ulng << 8) | prng_get_octet ();
done = (done << 8) | 255;
}

return ulng;
}

/* Returns a pseudo-random long in the range [0, LONG_MAX]. */
long
prng_get_long (void)
{
for (;;)
{
unsigned ulng = prng_get_ulong ();
if (ulng <= LONG_MAX)
return ulng;
}
}

/* Returns a pseudo-random unsigned int in the range [0,
UINT_MAX]. */
unsigned
prng_get_uint (void)
{
unsigned uint = prng_get_octet ();
unsigned done = 255;

while (done != UINT_MAX)
{
uint = (uint << 8) | prng_get_octet ();
done = (done << 8) | 255;
}

return uint;
}

/* Returns a pseudo-random int in the range [0, INT_MAX]. */
int
prng_get_int (void)
{
for (;;)
{
unsigned uint = prng_get_uint ();
if (uint <= INT_MAX)
return uint;
}
}

/* Returns a pseudo-random floating-point number from the uniform
distribution with range [0,1). */
double
prng_get_double (void)
{
for (;;)
{
unsigned long ulng = prng_get_ulong ();
if (ulng != ULONG_MAX)
return (double) ulng / ULONG_MAX;
}
}

/* Returns a pseudo-random floating-point number from the
distribution with mean 0 and standard deviation 1. (Multiply
the result by the desired standard deviation, then add the
desired mean.) */
double
prng_get_double _normal (void)
{
/* Knuth, _The Art of Computer Programming_, Vol. 2, 3.4.1C,
Algorithm P. */
static double next_normal = DBL_MAX;
double this_normal;

if (next_normal != DBL_MAX)
{
this_normal = next_normal;
next_normal = DBL_MAX;
}
else
{
double v1, v2, s;

do
{
double u1 = prng_get_double ();
double u2 = prng_get_double ();
v1 = 2.0 * u1 - 1.0;
v2 = 2.0 * u2 - 1.0;
s = v1 * v1 + v2 * v2;
}
while (s >= 1);

this_normal = v1 * sqrt (-2. * log (s) / s);
next_normal = v2 * sqrt (-2. * log (s) / s);
}

return this_normal;
}
----------------------------------------------------------------------
#ifndef PRNG_H_INCLUDED
#define PRNG_H_INCLUDED

#include <stddef.h>

void prng_seed (const void *, size_t);
unsigned char prng_get_octet (void);
unsigned char prng_get_byte (void);
void prng_get_bytes (void *, size_t);
unsigned long prng_get_ulong (void);
long prng_get_long (void);
unsigned prng_get_uint (void);
int prng_get_int (void);
double prng_get_double (void);
double prng_get_double _normal (void);

#endif /* prng.h */
----------------------------------------------------------------------
--
"There's only one thing that will make them stop hating you.
And that's being so good at what you do that they can't ignore you.
I told them you were the best. Now you damn well better be."
--Orson Scott Card, _Ender's Game_
Nov 14 '05
70 6327
"Scott Fluhrer" <sf******@ix.ne tcom.com> wrote in
news:KS******** ***********@new sread1.news.pas .earthlink.net:

"Hallvard B Furuseth" <h.b.furuseth(n ospam)@usit.uio (nospam).no> wrote
in message news:HB******** ******@bombur.u io.no...
Scott Fluhrer wrote:
> - Since you are using RC4, if you really want to be
> cryptographical ly secure, you'll need to discard some part of the
> keystream at initialization > time. Estimates as to how much you need to discard varies somewhat
> -- I've > seen estimates of 256 - 2048 bytes.


Why is that? Are the first bytes less random than later ones?

Well, no. It's just that by looking at the first bytes, you can get
some hints at what the seed (key) was. In addition, if you have
enough initial outputs from related seeds, well, you can figure out
what the seeds are.


This is true for every PRNG since they're deterministic. The question is
how hard is it given any subsequence of output given the algorithm - you
only need to determine the seed at any single point in the sequence to know
the whole sequence. Unless you're doing some behind-the-scenes magic with
the seed, I don't see how throwing away 'n' numbers helps you. Could you
explain further?

<snip>

Ian Woods
Nov 14 '05 #41
Peter Nilsson wrote:
About prng_seed: Why not change the size_t SIZE parameter to unsigned and, if KEY is
null and SIZE is non zero, seed on SIZE...?
(...)
That way, there is a simple mechanism for seeding by direct integers.


That _almost_ lets srand(seed) be implemented as prng_seed(0, seed).
srand(0) fails, however. So I think a prng_seed_uint( ) function is
needed in any case.

Also,
key = &size;
size = sizeof(size);


That does not give a repeatable sequence of pseudo-random numbers if
size has a padding bit which can be either 0 or 1. I'm afraid the
key needs to be built 'by hand':

unsigned char integer_key[sizeof size];
integer_key[0] = size;
#if UINT_MAX > UCHAR_MAX
{
int i = 1;
do {
integer_key[i++] = size >>= CHAR_BIT;
} while (i < (int)sizeof size);
}
#endif
key = &integer_key ;
size = sizeof size;

The #if is necessary because `size >>= CHAR_BIT' is invalid if size only
has CHAR_BIT value bits.

--
Hallvard
Nov 14 '05 #42
In <05************ ****@tematic.co m> Kevin Bracey <ke**********@t ematic.com> writes:
In message <bu**********@s unnews.cern.ch>
Da*****@cern.ch (Dan Pop) wrote:
In <87************ @pfaff.stanford .edu> Ben Pfaff <bl*@cs.stanfor d.edu> writes:
>/* Take advantage of inlining if possible. */
>#if __STDC_VERSION_ _ >= 199901L


Any use of __STDC_VERSION_ _ invokes undefined behaviour in a C90
implementation. Such an implementation can use it as a magic
identifier during preprocessing (e.g. the preprocessor's nasal demon
generator ;-) or simply define it as a macro with a value greater
than 199901L.


Ok, thanks for the DeathStation programming advice.

On a more practical note, what WOULD a reasonable value for a compiler in C90
mode to set __STDC_VERSION_ _ to, if it wanted to set it? (One reason for
wanting to set it might be to avoid warnings about it being an undefined
identifier treated as 0 in #if).

Presumably 1990xxL would make sense, but what is "xx"? Which month was C90
published (or reached whichever stage was equivalent to 199409/199901)? I
suppose 199000L would be safe whatever.


What if the implementor decided to include the full adoption date in
the definition of __STDC_VERSION_ _, so that it would become 1990mmddL?
Since there was no formal specification of the __STDC_VERSION_ _
macro at the time, such a decision is not a priori unreasonable.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #43
In <87************ @pfaff.stanford .edu> Ben Pfaff <bl*@cs.stanfor d.edu> writes:
Da*****@cern.c h (Dan Pop) writes:
In <87************ @pfaff.stanford .edu> Ben Pfaff <bl*@cs.stanfor d.edu> writes:
/* Take advantage of inlining if possible. */
#if __STDC_VERSION_ _ >= 199901L
Any use of __STDC_VERSION_ _ invokes undefined behaviour in a C90
implementation. Such an implementation can use it as a magic
identifier during preprocessing (e.g. the preprocessor's nasal demon
generator ;-) or simply define it as a macro with a value greater
than 199901L.


Only an actively malicious compiler would do so.


Wrong! See my previous post in the thread.
I'm not too interested in those.


Undefined behaviour is undefined behaviour in clc. Once you ignore it,
any hope of clc-compliance is gone. The standards we apply to Tisdale
must be valid for Pfaff, too.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #44
In message <bu**********@s unnews.cern.ch>
Da*****@cern.ch (Dan Pop) wrote:
In <05************ ****@tematic.co m> Kevin Bracey <ke**********@t ematic.com> writes:
On a more practical note, what WOULD a reasonable value for a compiler in
C90 mode to set __STDC_VERSION_ _ to, if it wanted to set it? (One reason
for wanting to set it might be to avoid warnings about it being an
undefined identifier treated as 0 in #if).

Presumably 1990xxL would make sense, but what is "xx"? Which month was C90
published (or reached whichever stage was equivalent to 199409/199901)? I
suppose 199000L would be safe whatever.


What if the implementor decided to include the full adoption date in
the definition of __STDC_VERSION_ _, so that it would become 1990mmddL?


The horse is dead, you can stop flogging now. Do you have a sensible answer
to the actual question asked?

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1223 503458
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Nov 14 '05 #45
In <ae************ ****@tematic.co m> Kevin Bracey <ke**********@t ematic.com> writes:
In message <bu**********@s unnews.cern.ch>
Da*****@cern.ch (Dan Pop) wrote:
In <05************ ****@tematic.co m> Kevin Bracey <ke**********@t ematic.com> writes:
> On a more practical note, what WOULD a reasonable value for a compiler in
> C90 mode to set __STDC_VERSION_ _ to, if it wanted to set it? (One reason
> for wanting to set it might be to avoid warnings about it being an
> undefined identifier treated as 0 in #if).
>
>Presumably 1990xxL would make sense, but what is "xx"? Which month was C90
>published (or reached whichever stage was equivalent to 199409/199901)? I
>suppose 199000L would be safe whatever.


What if the implementor decided to include the full adoption date in
the definition of __STDC_VERSION_ _, so that it would become 1990mmddL?


The horse is dead, you can stop flogging now. Do you have a sensible answer
to the actual question asked?


Methinks the actual question asked is off topic in this newsgroup.
If you need c.s.c, you should know where to find it.

BTW, wasn't I supposed to be plonked by you (due to my mental problems)?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #46
Da*****@cern.ch (Dan Pop) writes:
In <87************ @pfaff.stanford .edu> Ben Pfaff <bl*@cs.stanfor d.edu> writes:
Da*****@cern. ch (Dan Pop) writes:
In <87************ @pfaff.stanford .edu> Ben Pfaff <bl*@cs.stanfor d.edu> writes:

/* Take advantage of inlining if possible. */
#if __STDC_VERSION_ _ >= 199901L

Any use of __STDC_VERSION_ _ invokes undefined behaviour in a C90
implementation. Such an implementation can use it as a magic
identifier during preprocessing (e.g. the preprocessor's nasal demon
generator ;-) or simply define it as a macro with a value greater
than 199901L.
Only an actively malicious compiler would do so.


Wrong! See my previous post in the thread.


In which you wrote:
What if the implementor decided to include the full adoption date in
the definition of __STDC_VERSION_ _, so that it would become 1990mmddL?
Since there was no formal specification of the __STDC_VERSION_ _
macro at the time, such a decision is not a priori unreasonable.


Why would the implementor do so when C95 used 199409L, C99 used
199901L, and no other standard or (as far as I know) standard
draft defined __STDC_VERSION_ _ at all?
--
"When in doubt, treat ``feature'' as a pejorative.
(Think of a hundred-bladed Swiss army knife.)"
--Kernighan and Plauger, _Software Tools_
Nov 14 '05 #47
> > On BCC 5.5, Ben's PRNG does not compile, whereas the rand()
provided takes 0.95 nanoseconds.

The errors compiling Ben's PRNG were:
C:\docs\prog\c> bcc32 -c prng.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
prng.c:
Warning W8008 prng.c 135: Condition is always true in function prng_get_byte
Warning W8066 prng.c 145: Unreachable code in function prng_get_byte
This refers to "if (UCHAR_MAX == 255)" . I prefer to use #if
for comparisons like this that can be evaluated at compile-time
(I prefer not to turn off those compiler warnings, as sometimes
they show up genuine logic errors). Obviously this is just
a matter of style, unless you have a compiler with a really bad optimizer.
Error E2063 prng.c 244: Illegal initialization in function prng_get_double _normal
*** 1 errors in Compile ***

The error was at the line:
static double next_normal = DBL_MAX;


Bizarre. Can this be anything other than a bug in Borland C++?


From float.h;
#define DBL_MAX _max_dble
extern double _RTLENTRY _EXPDATA _max_dble;

[_RTLENTRY _EXPDATA is the calling convention for linking the C runtime
library, so I would suppose that is where _max_dble lives].

LDBL_MIN, FLT_MAX, LDBL_MAX are similarly declared (although
DBL_MIN, FLT_MIN, *_EPSILON, *_MAX_EXP, etc. are #defined as constants)

I'd say the compiler error is because in C (unlike C++),
static variables must be initialized to constants. It would be easy
to modify your code to work around this.

Does the Standard say that DBL_MAX must be a compile-time constant?
Nov 14 '05 #48
ol*****@inspire .net.nz (Old Wolf) writes:
> On BCC 5.5, Ben's PRNG does not compile, whereas the rand()
> provided takes 0.95 nanoseconds.
>
> The errors compiling Ben's PRNG were:
> C:\docs\prog\c> bcc32 -c prng.c
> Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
> prng.c:
> Warning W8008 prng.c 135: Condition is always true in function prng_get_byte
> Warning W8066 prng.c 145: Unreachable code in function prng_get_byte
This refers to "if (UCHAR_MAX == 255)" . I prefer to use #if
for comparisons like this that can be evaluated at compile-time
(I prefer not to turn off those compiler warnings, as sometimes
they show up genuine logic errors). Obviously this is just
a matter of style, unless you have a compiler with a really bad optimizer.
#if's are ugly, so I prefer to avoid them when it's reasonable.
> Error E2063 prng.c 244: Illegal initialization in function prng_get_double _normal
> *** 1 errors in Compile ***
>
> The error was at the line:
> static double next_normal = DBL_MAX;


Bizarre. Can this be anything other than a bug in Borland C++?


[...]
Does the Standard say that DBL_MAX must be a compile-time constant?


Yes. From C99 5.2.4.2.2:

The values given in the following list shall be replaced by
constant expressions with implementation-defined values that
are greater than or equal to those shown:

- maximum representable finite floating-point number, (1 - b-p)bemax
FLT_MAX 1E+37
DBL_MAX 1E+37
LDBL_MAX 1E+37

--
Go not to Usenet for counsel, for they will say both no and yes.
Nov 14 '05 #49
Hallvard B Furuseth <h.b.furuseth(n ospam)@usit.uio (nospam).no> wrote in message news:<HB******* *******@bombur. uio.no>...
Peter Nilsson wrote:
About prng_seed:

Why not change the size_t SIZE parameter to unsigned and, if KEY is
null and SIZE is non zero, seed on SIZE...?
(...)
That way, there is a simple mechanism for seeding by direct integers.


That _almost_ lets srand(seed) be implemented as prng_seed(0, seed).
srand(0) fails, however. So I think a prng_seed_uint( ) function is
needed in any case.

Also,
key = &size;
size = sizeof(size);


That does not give a repeatable sequence of pseudo-random numbers if
size has a padding bit which can be either 0 or 1. I'm afraid the
key needs to be built 'by hand':

unsigned char integer_key[sizeof size];
integer_key[0] = size;
#if UINT_MAX > UCHAR_MAX
{
int i = 1;
do {
integer_key[i++] = size >>= CHAR_BIT;
} while (i < (int)sizeof size);
}
#endif
key = &integer_key ;
size = sizeof size;

The #if is necessary because `size >>= CHAR_BIT' is invalid if size only
has CHAR_BIT value bits.


I prefer avoid such #if-s wherever reasonably possible, as just look
ugly (IMHO).

unsigned char integer_key[sizeof size];
size_t i;

integer_key[0] = size;
for (i = 1; i < sizeof size; i++)
{
size = size >> CHAR_BIT - 1 >> 1;
integer_key[i] = size;
}

key = &integer_key ;
size = sizeof integer_key;

Good compilers should optimise this.

But, I did note that time_t conversion suffers the same problem, and I
don't think that's quite as easy to fix, at least not if you want to
consider aberrant implementations .

--
Peter
Nov 14 '05 #50

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

Similar topics

0
1817
by: C. Titus Brown | last post by:
Hi all, just spent some time playing with cookielib in Python 2.4, trying to get the cookielib example to work with my mailman admindb page. The problem was that cookies weren't getting saved. The issue turned out to be that mailman sends out RFC 2965 cookies, which are by default rejected by cookielib. I don't remotely pretend to understand the issues involved; hence my post ;).
1
3906
by: praba kar | last post by:
Dear All, In Php we can print RFC 2822 formatted date by date('r') with parameter r. Then it will print the below format date. "Thu, 7 Apr 2005 01:46:36 -0300". I want to print same RFC 2822 format in python. Is it possible in python? . If possible kindly mention the function related to print RFC format date
47
2723
by: Jeff Relf | last post by:
Hi All, I plan on using the following C++ code to create nodes with unlimited children: // I would like to declare NodeT like this, // but it won't compile because Lnk_T is not defined yet. struct NodeT { Lnk_T Lnk ; };
3
5580
by: Dan | last post by:
Hi, I'm trying to call an RFC from a vb web service. I have created the proxy object with no worries but the return table always returns an error even when I get success running the RFC inside SAP. I login to the GUI under my own username but all the rfcs go through one rfc user. Before I go to the authorisations people, does this sounds like a permissions problem at the SAP end or has anyone else experienced problems like these? I...
2
1686
by: Nospam | last post by:
Powware Visual Programming is the world's first environment for creating software using the Powware Visual Programming Language on the Tablet PC. Be one of the first in the world to experience visual programming on the Tablet PC. Download a pre-release version and let us know what you think. This is a Request For Comments (RFC) to you, the programming community. Your feedback and input is important. Download Powware Visual...
1
1995
by: Alf P. Steinbach | last post by:
* Adam, in clc++m: > I have an unfortunate case where a single class wants to derive from two > existing classes: > > struct A { virtual long fun() = 0; }; > struct B { virtual bool fun() = 0; }; > struct Unfortunate : public A, public B { ??? }; I already answered this one (the exact same message text), apparently to Adam's satisfaction, in .
4
1800
by: Arild Hystad | last post by:
Hi, for some days now, I haven't been able to reach the clc-wiki. Is it terminated, moved or do I have a network problem? My bookmark says it is at http://clc-wiki.net/wiki/. Is this correct? -- Arild Hystad
2
1612
by: runner7 | last post by:
Can anyone tell me where the RFC definition syntax is documented? I am referring to such things as the use of <...>, , 1*, etc. I find this sort of thing in the RFC's for POP3, MIME, etc.
3
1654
by: Nindi | last post by:
On comp.lang.c++.moderated http://groups.google.co.uk/group/comp.lang.c++.moderated/browse_thread/thread/8250715711da7760?hl=en the following question was posted ------------------------------------------------------------------------------------------------------- Is this standard conformant to type cast ::opearator delete to a function of type (void (*)(void*)); Is not operator delete already a function of this type?
13
1746
by: Richard Heathfield | last post by:
I was recently asked about that old "K&R Answers" site I tried to maintain a few years back before Real Life got in the way. I directed the enquirer (who had expressed an interest in helping to maintain it) to http://clc-wiki.net/wiki/ which had taken the weight of that task off my hands. This morning I received an email from my correspondent, saying the site appeared to be dead. I tried to connect to it myself just a moment ago, and...
0
11279
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
10870
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
10981
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
10499
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
9673
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...
1
8047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7205
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
5893
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
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.