473,799 Members | 3,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using "!!" in "c"

Hello,
I saw in some open source projects a use of "!!" in "C" code;
for example:
in some header file
#define event_pending(v ) \
(!!(v)->vcpu_info->evtchn_upcall_ pending & \
!(v)->vcpu_info->evtchn_upcall_ mask)

whereas evtchn_upcall_p ending is of type unsigned char
(and also evtchn_upcall_m ask is of type unsigned char).

What does "!!" operator do in this case ? Any ideas?
MR

Jan 18 '06
43 2761
On 2006-01-19, pemo <us***********@ gmail.com> wrote:
That invokes undefined behavior.

"boo" yields a char* value. The "!" operator yields 1 if its operand
compares equal to 0, 0 otherwise. In this case, it compares the char*
value to a null pointer value. Since "boo" cannot be a null pointer,
!"boo" is guaranteed to yield 0. Applying "!" again yields the int
value 1.

So the above is equivalent to

printf("%p\n", (void*)1);

The conversion of the int value 1 to void* may yield a trap
representation; passing this to printf() (or doing anything else with
it) invokes undefined behavior.

Interesting, so something like this is basically illegal/non-portable now?

void (* n)(void) = (void(*)(void)) 42;

n();

Years ago I used to use something like the above for invoking interrupt
routines.


He's getting a bit ahead of himself - it is not undefined, it's
implementation-defined. But it's _always_ been non-portable - what's an
interrupt routine?
Jan 19 '06 #31

"Jordan Abel" <ra*******@gmai l.com> wrote in message
news:sl******** *************** @random.yi.org. ..
On 2006-01-19, pemo <us***********@ gmail.com> wrote:
That invokes undefined behavior.

"boo" yields a char* value. The "!" operator yields 1 if its operand
compares equal to 0, 0 otherwise. In this case, it compares the char*
value to a null pointer value. Since "boo" cannot be a null pointer,
!"boo" is guaranteed to yield 0. Applying "!" again yields the int
value 1.

So the above is equivalent to

printf("%p\n", (void*)1);

The conversion of the int value 1 to void* may yield a trap
representation; passing this to printf() (or doing anything else with
it) invokes undefined behavior.

Interesting, so something like this is basically illegal/non-portable
now?

void (* n)(void) = (void(*)(void)) 42;

n();

Years ago I used to use something like the above for invoking interrupt
routines.


He's getting a bit ahead of himself - it is not undefined, it's
implementation-defined. But it's _always_ been non-portable - what's an
interrupt routine?


Interrupt routine. A routine (usually held in ROM) that is normally
[caused] to be invoked by some hardware 'event' [or 'interrupt'] - e.g.,
when the hardware clocks ticks, a hardware interrupt is triggered so that
the OS etc can keep track of the current time, and the fact that the time
has just changed, i.e., this saves the OS from polling here. The location
of the routine[s] that need calling when these events occur were held in a
table at a fixed location. So, if you were writing some lowish level code
that might want to interact with, say, the harddrive controller, it was
often nice to do at least some part of this via the harddrive's documented
interrupt interface.

So, you'd often have to fetch an interrupt routine's address, and then call
it ...

typically, it looked something like this:

typedef Interrupts int; // Used as a function pointer 'value' for any
interrupt routine.

Interrupts * inttab;

// Base address of int table. inttab[index] yields index interrupt vector.
The actual addresses are already there - BIOS!
//
inttab = (Interrupts *)0; // 0 = base address on int table. inttab[x]
yields address of x's interrupt vector's service routine.

....

// Trigger int 10

void(*n)();

// Get int 10's service routine address.

n = (void)(*)())int tab[10];

// Invoke int 10.

n();



Jan 19 '06 #32
pemo wrote:
"Jordan Abel" <ra*******@gmai l.com> wrote in message
news:sl******** *************** @random.yi.org. ..
On 2006-01-19, pemo <us***********@ gmail.com> wrote:
That invokes undefined behavior.

"boo" yields a char* value. The "!" operator yields 1 if its operand
compares equal to 0, 0 otherwise. In this case, it compares the char*
value to a null pointer value. Since "boo" cannot be a null pointer,
!"boo" is guaranteed to yield 0. Applying "!" again yields the int
value 1.

So the above is equivalent to

printf("%p\n", (void*)1);

The conversion of the int value 1 to void* may yield a trap
representation; passing this to printf() (or doing anything else with
it) invokes undefined behavior.

Interesting, so something like this is basically illegal/non-portable
now?

void (* n)(void) = (void(*)(void)) 42;

n();

Years ago I used to use something like the above for invoking interrupt
routines. He's getting a bit ahead of himself - it is not undefined, it's
implementation-defined. But it's _always_ been non-portable - what's an
interrupt routine?


Interrupt routine. A routine (usually held in ROM) that is normally


I'm sure Jordan, Keith and most of the other regulars know what an ISR
is. It does not change the fact that what you are suggesting is
non-portable.

Lets take the issue of where the interrupt vector table is. I've used
systems with it at the bottom of memory next to the reset vector and
therefore in ROM, I've used systems with it at the bottom of memory with
the reset vector at the tom, so the interrupt vector table was in RAM,
I've used systems where the location of the interrupt vector table is
configurable, so it could be anywhere! That show your hard coded address
is non-portable.

I've also used sytems where the interupt vector table does *not* contain
some kind of jump/call instruction, so you would actually need another
level of indirection on those systems.

<snip>
table at a fixed location. So, if you were writing some lowish level code
that might want to interact with, say, the harddrive controller, it was
often nice to do at least some part of this via the harddrive's documented
interrupt interface.
Not something I've needed to do, but i'll accept it's been useful to
you. However, useful does not mean portable. So now lets deal with the
issue of calling an ISR. I've used systems where the return call/return
mechanism for an ISR was not the same as the mechanism for a normal
function. So to call an ISR you would actually have to use a CALLI
instruction, when the compiler would also emit a CALL instruction. So,
even having used some magic to get the address of the ISR you *still*
can't call it from C on a system like this and if you try you will crash
your program even if the ISR does nothing other than return.
So, you'd often have to fetch an interrupt routine's address, and then call
it ...


<snip non-portable code>

Which you can't do portably. This is not to say you can't do it at all,
on some systems you can.

The conversion from integer to pointer is implementation defined (apart
from an integer *constant* of 0) and could generate a trap
representation. If it generates a trap representation then evaluating it
(which you have to do to assign it to a pointer unless you cheat and
do it via an unsigned char pointer) invokes undefined behaviour. Even if
you manage to get past that, you still leave standard C a long way
behind when you try calling it.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Jan 19 '06 #33
pemo wrote:
"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org...
"pemo" <us***********@ gmail.com> writes:
[snip]
!! is a good way of turning a scalar value into 1 or 0. So is (value, 0) (i.e., a comma operator). It turns a scalar value
into 1 or 0. It just happens to be 0.


What's the point here?


I believe that Keith was just pointing out that your specification of
what !! does was incomplete. What he wrote met your specification but
would generally be pointless in real code (there are potentially some
exceptions) and does not do what !! does.
!! maps 0 to 0, and any non-zero value to 1, for any scalar operand.
For example, this

printf("%p\n", (void *)"boo");

will output some value that's not 0, and very unlikely to be 1, e.g.,
0040300
It will output some implementation-specific sequence of printing
characters. The sequence may or may not look like a number.


Can you explain this comment too? Is it an allusion to some obscure
minutiae in the std, like "In reality, an implementation is free to encode
an address such that it is displayed in egyptian hieroglyphics"?


One very common format of output is something like "1234:5678" , another
is something like "0x12345678 ". You will note that the first does not
look like a number because of the colon. Another common output is
something like "(null)" which looks even less like a number. What %p
prints can be in any format as long as it can be read by a %p in a scanf
on that implementation and yield the original pointer. Frequently
(though it is not required) it is whatever format is generally used in
printed material for addresses, and when an address on a machine is not
a simple thing (e.g. segment and offset as supported by x86 processors)
that is quite likely to mean the output won't look like a simple
integer. Egyptian hieroglyphics could legally be used as long they were
part of the execution character set and scanf processed them appropriately.
However, this

printf("%p\n", (void *)!!"boo");

will output 000001, e.g., '1'

That invokes undefined behavior.

"boo" yields a char* value. The "!" operator yields 1 if its operand
compares equal to 0, 0 otherwise. In this case, it compares the char*
value to a null pointer value. Since "boo" cannot be a null pointer,
!"boo" is guaranteed to yield 0. Applying "!" again yields the int
value 1.

So the above is equivalent to

printf("%p\n", (void*)1);

The conversion of the int value 1 to void* may yield a trap
representation; passing this to printf() (or doing anything else with
it) invokes undefined behavior.


Well, it only conditionally invokes undefined behaviour. If it happens
not to produce a trap representation then it is only implementation
defined behaviour IIRC. Of course, it should still generally be treated
as undefined behaviour.
Interesting, so something like this is basically illegal/non-portable now?

void (* n)(void) = (void(*)(void)) 42;

n();

Years ago I used to use something like the above for invoking interrupt
routines.


What you show the above has *always* been non-portable.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Jan 19 '06 #34
<snip>
So is (value, 0) (i.e., a comma operator). It turns a scalar value
into 1 or 0. It just happens to be 0.
What's the point here?

I believe that Keith was just pointing out that your specification of what !! does was incomplete. What he wrote met your specification but
would generally be pointless in real code (there are potentially some
exceptions) and does not do what !! does.
If that *IS* the case, it seems um, rather unnecessarily pedantic - I
believe that what I said was clear enough - and corrrect in as far as it
went: and I also didn't say it was the only way to do something .... so why
point out alternatives? Maybe it's necessary to produce litanies containing
alternative possibilities for each non-exhaustive statement ever made here
sometimes?

printf("%p\n", (void *)"boo");

will output some value that's not 0, and very unlikely to be 1, e.g.,
0040300
It will output some implementation-specific sequence of printing
characters. The sequence may or may not look like a number.


Can you explain this comment too? Is it an allusion to some obscure
minutiae in the std, like "In reality, an implementation is free to encode
an address such that it is displayed in egyptian hieroglyphics"?

One very common format of output is something like "1234:5678" , another is something like "0x12345678 ". <snip>
Ah, so it was as I expected - an allusion to some obscure minutiae [well, it
is isn't it - letter-of-the-law-correct-or-not] that seems picky and
generally non-constructive. The two examples you gave look like numbers to
me. And I would hazard a guess that most every compiler outputs something
similar - even if it doesn't *have to*. So, saying that a compiler *could*
output this in a braille encoding of the morse-code interpretation of
egyptian hieroglyphics is kinda like saying that there is a remote
possibility that you *could* pick up a book which is written in English -
but that you can't read - because the author decided to choose a remote
vocabulary and to 'encode' his/her prose in such an impenetrable way as it
make it more or less impossible. Both situations *could* exist, but both
are, in reality, unlikely to - so what's the point in making a noise about
it?

Interesting, so something like this is basically illegal/non-portable
now?

void (* n)(void) = (void(*)(void)) 42;

n();

Years ago I used to use something like the above for invoking interrupt
routines.


What you show the above has *always* been non-portable.

Yes [I know!], my V.POOR wording - the question ought to have been ... is
the code illegal, without going through the unsigned char * route?

Jan 19 '06 #35
pemo wrote:

Please quote properly and leave in the attribution lines. If OE gives
you problems you can try searching for and using QuoteFix. You were
quoting properly previously and this time I'm going to fix it.
Flash Gordon wrote:
pemo wrote:
<snip>
So is (value, 0) (i.e., a comma operator). It turns a scalar value
into 1 or 0. It just happens to be 0.
What's the point here?
I believe that Keith was just pointing out that your specification of

what !! does was incomplete. What he wrote met your specification but
would generally be pointless in real code (there are potentially some
exceptions) and does not do what !! does.


If that *IS* the case, it seems um, rather unnecessarily pedantic -


This is CLC, people *are* pedantic here!
I
believe that what I said was clear enough - and corrrect in as far as it
went: and I also didn't say it was the only way to do something .... so why
point out alternatives? Maybe it's necessary to produce litanies containing
alternative possibilities for each non-exhaustive statement ever made here
sometimes?
Pointing out holes in what people say is not uncommon here.
> printf("%p\n", (void *)"boo");
>
> will output some value that's not 0, and very unlikely to be 1, e.g.,
> 0040300
It will output some implementation-specific sequence of printing
characters. The sequence may or may not look like a number.
Can you explain this comment too? Is it an allusion to some obscure
minutiae in the std, like "In reality, an implementation is free to encode
an address such that it is displayed in egyptian hieroglyphics"?
One very common format of output is something like "1234:5678" , another
is something like "0x12345678 ". <snip>


Ah, so it was as I expected - an allusion to some obscure minutiae [well, it


You think x86 based machines are obscure minutiae?
is isn't it - letter-of-the-law-correct-or-not] that seems picky and
generally non-constructive. The two examples you gave look like numbers to
me. And I would hazard a guess that most every compiler outputs something
Numbers do not have colons in the middle, at least not in any
representation I've come across and "(null)" is definitely *not* a
number which was another example I gave but you snipped.

<snip>
make it more or less impossible. Both situations *could* exist, but both
are, in reality, unlikely to - so what's the point in making a noise about
it?


Implementations which print out the address with a : in the middle are
very real, and the processor for which such implementations were written
are still in current use.
Interesting, so something like this is basically illegal/non-portable
now?

void (* n)(void) = (void(*)(void)) 42;

n();

Years ago I used to use something like the above for invoking interrupt
routines.

What you show the above has *always* been non-portable.


Yes [I know!], my V.POOR wording - the question ought to have been ... is
the code illegal, without going through the unsigned char * route?


Subject to me missing errors what you are suggesting is perfectly
acceptable syntactically and the compiler is not required to produce a
diagnostic. So in that sense it is "legal". However, since it invokes
undefined behaviour it is in another sense "illegal". So take your pick.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Jan 19 '06 #36
"pemo" <us***********@ gmail.com> writes:
"Keith Thompson" <ks***@mib.or g> wrote in message
news:ln******** ****@nuthaus.mi b.org...
"pemo" <us***********@ gmail.com> writes:
[snip]
!! is a good way of turning a scalar value into 1 or 0.


So is (value, 0) (i.e., a comma operator). It turns a scalar value
into 1 or 0. It just happens to be 0.


What's the point here?
!! maps 0 to 0, and any non-zero value to 1, for any scalar operand.
For example, this

printf("%p\n", (void *)"boo");

will output some value that's not 0, and very unlikely to be 1, e.g.,
0040300

It will output some implementation-specific sequence of printing
characters. The sequence may or may not look like a number.


Can you explain this comment too? Is it an allusion to some obscure
minutiae in the std, like "In reality, an implementation is free to encode
an address such that it is displayed in egyptian hieroglyphics"?


I was going to post an explanation of what I meant, but Flash Gordon's
response explains it at least as well as I would have.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 19 '06 #37
"pemo" <us***********@ gmail.com> writes:
<snip>
So is (value, 0) (i.e., a comma operator). It turns a scalar value
into 1 or 0. It just happens to be 0.


What's the point here?

I believe that Keith was just pointing out that your specification of

what !! does was incomplete. What he wrote met your specification but
would generally be pointless in real code (there are potentially some
exceptions) and does not do what !! does.
If that *IS* the case, it seems um, rather unnecessarily pedantic - I
believe that what I said was clear enough - and corrrect in as far as it
went: and I also didn't say it was the only way to do something .... so why
point out alternatives? Maybe it's necessary to produce litanies containing
alternative possibilities for each non-exhaustive statement ever made here
sometimes?


(A number of attributions were snipped. I wrote the text starting
with "So is (value, 0)", pemo wrote the text starting with "What's the
point here?", and Flash Gordon wrote the text starting with "I believe
that Keith was". Please leave attributions in place. Thanks.)

What you wrote was:

!! is a good way of turning a scalar value into 1 or 0.

That's not a useful specification unless you also specify *when*
it yields 0 and when it yields 1. By itself, it doesn't provide any
clue of why you'd want to turn a scalar value into 1 or 0. I was just
emphasizing the fact that !! maps 0 to 0 and all non-zero mappings
to 1. There are many many other possible mappings.

Whether I was being overly pedantic is a matter of opinion, of course.
I likely wouldn't have bothered mentioning it if I weren't commenting
on other things in your article.
printf("%p\n", (void *)"boo");

will output some value that's not 0, and very unlikely to be 1, e.g.,
0040300

It will output some implementation-specific sequence of printing
characters. The sequence may or may not look like a number.


Can you explain this comment too? Is it an allusion to some obscure
minutiae in the std, like "In reality, an implementation is free to encode
an address such that it is displayed in egyptian hieroglyphics"?

One very common format of output is something like "1234:5678" , another

is something like "0x12345678 ". <snip>

Ah, so it was as I expected - an allusion to some obscure minutiae [well, it
is isn't it - letter-of-the-law-correct-or-not] that seems picky and
generally non-constructive. The two examples you gave look like numbers to
me. And I would hazard a guess that most every compiler outputs something
similar - even if it doesn't *have to*. So, saying that a compiler *could*
output this in a braille encoding of the morse-code interpretation of
egyptian hieroglyphics is kinda like saying that there is a remote
possibility that you *could* pick up a book which is written in English -
but that you can't read - because the author decided to choose a remote
vocabulary and to 'encode' his/her prose in such an impenetrable way as it
make it more or less impossible. Both situations *could* exist, but both
are, in reality, unlikely to - so what's the point in making a noise about
it?


No, this is not "some obscure minutiae", this is part of a basic
understanding of the language.

Here's what the standard says about the "%p" format for the *printf()
functions:

The argument shall be a pointer to void. The value of the pointer
is converted to a sequence of printing characters, in an
implementation-defined manner.

There's also some wording for the *scanf() functions saying that it
can read the same format produced by *printf().

There is no implication that the output looks anything like a number,
and portable code cannot depend on any particular output format. It
happens that most implementations use something that looks like a
numeric format, possibly with extra decorations (leading "0x",
inserted ':', etc.). One system I just tried prints a hexadecimal
string *without* a leading "0x", such as "ffbff374", which happens to
be a valid identifier.

It's tempting to think that addresses are just another kind of number,
but that's a dangerous conceptual trap. They're often implemented
that way, but a C address or pointer value should be thought of as an
opaque entity that can be used to access other entities.

In any case, the example you chose didn't illustrate the point you
were making very well.
Interesting, so something like this is basically illegal/non-portable
now?

void (* n)(void) = (void(*)(void)) 42;

n();

Years ago I used to use something like the above for invoking interrupt
routines.


That's legal but non-portable. The conversion of the int value 42 to
a pointer-to-function type yields an implementation-defined result; it
could be a trap representation. If there doesn't happen to be a
function of the proper type whose address is whatever you get by
converting the int value 42, Bad Things Will Happen.

Of course this is a perfectly legitimate thing to do as long as you
really know what's going on and you're aware that it's non-portable.

On some systems, converting an integer to a pointer-to-function might
*never* yield a meaningful value. (For example, I think the AS/400
has a very exotic format for function pointers.)

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 19 '06 #38

"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:kr******** ****@news.flash-gordon.me.uk...
pemo wrote:

Please quote properly and leave in the attribution lines. If OE gives you
problems you can try searching for and using QuoteFix. You were quoting
properly previously and this time I'm going to fix it.

Sorry, I'm a terrible poster, and I'll look at QuoteFix.

Flash Gordon wrote:
pemo wrote:
<snip>

> So is (value, 0) (i.e., a comma operator). It turns a scalar value
> into 1 or 0. It just happens to be 0.
What's the point here?

I believe that Keith was just pointing out that your specification of
what !! does was incomplete. What he wrote met your specification but
would generally be pointless in real code (there are potentially some
exceptions) and does not do what !! does.


If that *IS* the case, it seems um, rather unnecessarily pedantic -


This is CLC, people *are* pedantic here!
I
believe that what I said was clear enough - and corrrect in as far as it
went: and I also didn't say it was the only way to do something .... so
why point out alternatives? Maybe it's necessary to produce litanies
containing alternative possibilities for each non-exhaustive statement
ever made here sometimes?


Pointing out holes in what people say is not uncommon here.
>> printf("%p\n", (void *)"boo");
>>
>> will output some value that's not 0, and very unlikely to be 1, e.g.,
>> 0040300
> It will output some implementation-specific sequence of printing
> characters. The sequence may or may not look like a number.
Can you explain this comment too? Is it an allusion to some obscure
minutiae in the std, like "In reality, an implementation is free to
encode an address such that it is displayed in egyptian hieroglyphics"?

One very common format of output is something like "1234:5678" , another
is something like "0x12345678 ". <snip>


Ah, so it was as I expected - an allusion to some obscure minutiae [well,
it


You think x86 based machines are obscure minutiae?

No, not that! [see also below], rather that the comment I thought
uneccesary, *was* (IMHO)

It was essentially 'pulling me up' for stating that the output *might* be
0040300 [or 0123456, or 123, or 342342342342342 34] - and that I didn't add
some, 'oh, and it might just be in output in hieroglyphics on your
implementation' !

Maybe the point was made so that some 'knumb nuts' didn't get the wrong end
of the stick, or maybe it was made just to remind someone [who I don't know]
that the output might actually be different from the example - maybe it was
just made to personally annoy me - I dunno, but it pissed me off anyway!
is isn't it - letter-of-the-law-correct-or-not] that seems picky and
generally non-constructive. The two examples you gave look like numbers
to me. And I would hazard a guess that most every compiler outputs
something
Numbers do not have colons in the middle, at least not in any
representation I've come across and "(null)" is definitely *not* a number
which was another example I gave but you snipped.

Yes, my phd wasn't wasted - and I've noticed that numbers don't have numbers
in the middle **using standard notation [see below]** - but they *can* have
camels in the middle if *you* want them to - and if you want to use such
notation personally - as some legal characterisatio n of some abstract scalar
view of the world. Which comes back to a problem with this ... if the
output can be anything, well, we ought to always include standard
disclaimers about *any* claim we make here regarding *any* output.
Ridiculus - so, lets point it out when it's properly pertinent, and not just
when we just feel the urge to bump our gums, and add some white noise into
the system?
Numbers do not have colons in the middle


Actually, that's rubbish, as I used them for many years with segmented
architectures - such numbers then meant as much to me - as in they had an
intuitive meaning for me (as 123 does now/then). This last bit is a little
like the 'pulling up' I had

'Actually the output of pemo's mathematics will be a pemo
implementation-specific sequence of printing
characters [maybe]. The sequence may or may not look like any number you're
used to'

Irksome eh?


Jan 19 '06 #39
On 2006-01-19, Flash Gordon <sp**@flash-gordon.me.uk> wrote:
Subject to me missing errors what you are suggesting is perfectly
acceptable syntactically and the compiler is not required to produce a
diagnostic. So in that sense it is "legal". However, since it invokes
undefined behaviour it is in another sense "illegal". So take your pick.


It does not. The conversion is implementation-defined. While the program
still cannot be strictly conforming, there is no undefined behavior
involved.

If I do this on my system, I will get a segmentation fault. Furthermore,
it will happen when the pointer is dereferenced, not when it is
assigned. While there is no documentation that actually says this _as
such_, all parts of the chain of events from the int/pointer conversion
to the mapping of the virtual memory page containing address 42 to the
conditions under which the signal in question will be raised are
documented _somewhere_, and it can be inferred from these facts without
ever attempting to enter, compile, or run the code.

I believe that the implementation is free to leave certain
implementation-defined aspects undefined, such as if the address
0x80484f8 were instead used. This happens to, in my test program, be the
address where the symbol 'main' is mapped. Since the address is in a
text page, i can attempt to call it and arbitrary code may be run, in
this case, a recursive call to main(). However, none of this is defined
by my implementation. However, from the point of view of the C standard,
implementation-undefined behavior is still implementation-defined.
Jan 19 '06 #40

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

Similar topics

1
433
by: Mehul Patel | last post by:
Our .Net team have been pondering about using keyword. We are using streams FileStream and BufferedStream. We use using keyword at FileStream, and not BufferedStream which wraps FileStream. So bunch of people said what if exception occurs buffered stream is not closed. My Argument is over advantages of using 'Using' keyword. First Advantage being -- Using used for Dispose (Deterministic
2
5946
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using X509Certificate ( *.cer file ) so that it can be used to email as attachment. The real part is Encrypting using X509Certificate and CryptoServiceProvider.
1
567
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I want to use a callback from the client side to update webcontrols based on user input without using postback. I am seeking a way to stop the compile errors. using System; using System.Data;
4
642
by: Marshall Mills | last post by:
As I understand it, loaded statement, a using declaration should be all I need to see an enum from within a namespace. The below code works fine with class, struct, and union. What gives? As the code says, if I employ the using directive, I'm ok. /* built with Visual C++ 6, SP 5 */ namespace Traffic { enum Light { red, yellow, green }; }
10
2663
by: Christopher Benson-Manica | last post by:
Why can't I use a class destructor in a using declaration: using MyClass::~MyClass; ? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
17
3519
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example using std::cin; using std::cout;
2
2916
by: trying_to_learn | last post by:
im in the primary stages of learning C++. The book im learning from says Dont use using namespace.. directive in header file However im trying to make the following header file.I need to include <string> header file and also will have to say using namespace std to make the string class visible. qn)how do i resolve the requirement of *not* using the "using" directive in the header file and at the same time declare my structure in the...
8
4917
by: Petter Reinholdtsen | last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to compile a program using 'using namespace std;' at the top. The reason seem to be that the compiler refuses to accept 'using namespace std;' unless the std namespace was declared first. This triggered my curiosity, and I tried to find out what the ANSI C++ standard had to say about this. I'm unable to find a conclusion, and hope someone here have a clue to spare. ...
14
2176
by: john.burton.email | last post by:
I've done some extensive searching and can't seem to find an answer to this - Is it correct to using "using" with templates, for example: using std::vector; Or do I need to specify the type too: using std::vector<int>; Both seem to "work" on the compiler I have and I can't find any documentation saying which is correct, or are both correct?
5
5719
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ================================================================= Error 19: "CORBAManagerMessages.h", line 4 # Unexpected 'std'. using std::string; ^^^
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10249
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
10219
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
10025
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
9068
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
7563
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
5461
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
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.