* Re: Significance of using + before function calls.
2006-03-15 12:59 Significance of using + before function calls Vamsi
@ 2006-03-15 7:51 ` Steve Graegert
2006-03-15 7:58 ` Per Jessen
2006-03-15 7:59 ` Joel M. Pareja
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Steve Graegert @ 2006-03-15 7:51 UTC (permalink / raw)
To: linux-c-programming
On 3/15/06, Vamsi <krishna.vamsi@wipro.com> wrote:
> Hi List,
>
> i have seen a code snippet which starts with + symbol,
>
> +system("ls -l");
>
> what is the significance of using + symbol before system.
>
> i also tried using + before printf ,, like +printf("Some text"); and it
> is compiling and working tooo,,
>
> Can somebody clarify wht does that + signify??
The unary plus operator returns the value of an expression. Neither
the unary plus nor unary minus operators produce lvalues and is of
limited use.
\Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Significance of using + before function calls.
2006-03-15 7:51 ` Steve Graegert
@ 2006-03-15 7:58 ` Per Jessen
2006-03-15 12:11 ` Steve Graegert
0 siblings, 1 reply; 10+ messages in thread
From: Per Jessen @ 2006-03-15 7:58 UTC (permalink / raw)
To: linux-c-programming
Steve Graegert wrote:
>
> The unary plus operator returns the value of an expression. Neither
> the unary plus nor unary minus operators produce lvalues and is of
> limited use.
So what might be the intention of someone using it like the OP
described? It doesn't make much sense, right?
Per Jessen
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Significance of using + before function calls.
2006-03-15 12:59 Significance of using + before function calls Vamsi
2006-03-15 7:51 ` Steve Graegert
@ 2006-03-15 7:59 ` Joel M. Pareja
2006-03-15 13:40 ` Vamsi
2006-03-15 10:09 ` Glynn Clements
2006-03-15 20:34 ` Tomas Janousek
3 siblings, 1 reply; 10+ messages in thread
From: Joel M. Pareja @ 2006-03-15 7:59 UTC (permalink / raw)
To: linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 700 bytes --]
The placement of '+' or '-' before the function call is performing a
unary operator on the return value of the function.
Vamsi wrote:
> Hi List,
>
> i have seen a code snippet which starts with + symbol,
>
> +system("ls -l");
>
> what is the significance of using + symbol before system.
>
> i also tried using + before printf ,, like +printf("Some text"); and it
> is compiling and working tooo,,
>
> Can somebody clarify wht does that + signify??
>
> Thank You.
>
> -Vamsi
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3178 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Significance of using + before function calls.
2006-03-15 13:40 ` Vamsi
@ 2006-03-15 8:16 ` Joel M. Pareja
0 siblings, 0 replies; 10+ messages in thread
From: Joel M. Pareja @ 2006-03-15 8:16 UTC (permalink / raw)
To: linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 1422 bytes --]
That must be a typographical error.
Because '+' does nothing to the return value of the function.
Also because there is no lvalue in the expression.
But with '-', there is an effect.
int dummy_func() { return 5; }
int num = -dummy_func();
As a result, num will be '-5'.
Vamsi wrote:
>
> Joel M. Pareja wrote:
>
>> The placement of '+' or '-' before the function call is performing a
>> unary operator on the return value of the function.
>
> does it server any purpose ? , unary '+' operator will not have any
> significance effect on the return value
>
> -Vamsi
>
>>
>> Vamsi wrote:
>>
>>> Hi List,
>>>
>>> i have seen a code snippet which starts with + symbol,
>>>
>>> +system("ls -l");
>>>
>>> what is the significance of using + symbol before system.
>>>
>>> i also tried using + before printf ,, like +printf("Some text"); and
>>> it is compiling and working tooo,,
>>>
>>> Can somebody clarify wht does that + signify??
>>>
>>> Thank You.
>>>
>>> -Vamsi
>>>
>>> -
>>> To unsubscribe from this list: send the line "unsubscribe
>>> linux-c-programming" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3178 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Significance of using + before function calls.
2006-03-15 12:59 Significance of using + before function calls Vamsi
2006-03-15 7:51 ` Steve Graegert
2006-03-15 7:59 ` Joel M. Pareja
@ 2006-03-15 10:09 ` Glynn Clements
2006-03-15 15:48 ` Vamsi
2006-03-15 20:34 ` Tomas Janousek
3 siblings, 1 reply; 10+ messages in thread
From: Glynn Clements @ 2006-03-15 10:09 UTC (permalink / raw)
To: Vamsi; +Cc: linux-c-programming
Vamsi wrote:
> i have seen a code snippet which starts with + symbol,
>
> +system("ls -l");
I suspect that the "code snippet" in question comes from the output of
"diff -u", and the + is part of the diff syntax, not part of the code.
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Significance of using + before function calls.
2006-03-15 7:58 ` Per Jessen
@ 2006-03-15 12:11 ` Steve Graegert
0 siblings, 0 replies; 10+ messages in thread
From: Steve Graegert @ 2006-03-15 12:11 UTC (permalink / raw)
To: linux-c-programming
On 3/15/06, Per Jessen <per@computer.org> wrote:
> Steve Graegert wrote:
> >
> > The unary plus operator returns the value of an expression. Neither
> > the unary plus nor unary minus operators produce lvalues and is of
> > limited use.
>
> So what might be the intention of someone using it like the OP
> described? It doesn't make much sense, right?
I suppose it's there for a clean implementation of operators in C.
While the unary minus returns the negative of the operand the unary
plus returns the value to avoid ambiguity, i.e. shall the unary plus
return the positive of a negative operand, as the unary minus does?
IMHO, not a result I'd expect.
\Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* Significance of using + before function calls.
@ 2006-03-15 12:59 Vamsi
2006-03-15 7:51 ` Steve Graegert
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Vamsi @ 2006-03-15 12:59 UTC (permalink / raw)
To: linux-c-programming
Hi List,
i have seen a code snippet which starts with + symbol,
+system("ls -l");
what is the significance of using + symbol before system.
i also tried using + before printf ,, like +printf("Some text"); and it
is compiling and working tooo,,
Can somebody clarify wht does that + signify??
Thank You.
-Vamsi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Significance of using + before function calls.
2006-03-15 7:59 ` Joel M. Pareja
@ 2006-03-15 13:40 ` Vamsi
2006-03-15 8:16 ` Joel M. Pareja
0 siblings, 1 reply; 10+ messages in thread
From: Vamsi @ 2006-03-15 13:40 UTC (permalink / raw)
To: Joel M. Pareja; +Cc: linux-c-programming
Joel M. Pareja wrote:
> The placement of '+' or '-' before the function call is performing a
> unary operator on the return value of the function.
does it server any purpose ? , unary '+' operator will not have any
significance effect on the return value
-Vamsi
>
> Vamsi wrote:
>
>> Hi List,
>>
>> i have seen a code snippet which starts with + symbol,
>>
>> +system("ls -l");
>>
>> what is the significance of using + symbol before system.
>>
>> i also tried using + before printf ,, like +printf("Some text"); and
>> it is compiling and working tooo,,
>>
>> Can somebody clarify wht does that + signify??
>>
>> Thank You.
>>
>> -Vamsi
>>
>> -
>> To unsubscribe from this list: send the line "unsubscribe
>> linux-c-programming" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Significance of using + before function calls.
2006-03-15 10:09 ` Glynn Clements
@ 2006-03-15 15:48 ` Vamsi
0 siblings, 0 replies; 10+ messages in thread
From: Vamsi @ 2006-03-15 15:48 UTC (permalink / raw)
To: Glynn Clements; +Cc: linux-c-programming
Glynn Clements wrote:
>Vamsi wrote:
>
>
>
>>i have seen a code snippet which starts with + symbol,
>>
>>+system("ls -l");
>>
>>
>
>I suspect that the "code snippet" in question comes from the output of
>"diff -u", and the + is part of the diff syntax, not part of the code.
>
>
>
No, i verified it is not a patch, or the output of diff.
Thank You.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Significance of using + before function calls.
2006-03-15 12:59 Significance of using + before function calls Vamsi
` (2 preceding siblings ...)
2006-03-15 10:09 ` Glynn Clements
@ 2006-03-15 20:34 ` Tomas Janousek
3 siblings, 0 replies; 10+ messages in thread
From: Tomas Janousek @ 2006-03-15 20:34 UTC (permalink / raw)
To: linux-c-programming
Hello,
Vamsi napsal(a):
> Can somebody clarify wht does that + signify??
It suppresses the warning about ignored returned value returned by
splint, for example.
--
.--------- Tomáš Janoušek a.k.a. Liskni_si ---------.
: NOMI team, developer, http://tomi.nomi.cz/ tomi@nomi.cz :
' JID:liskni_si@jabber.cz, ICQ#161807083, tel:+420608876277 '
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-03-15 20:34 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-15 12:59 Significance of using + before function calls Vamsi
2006-03-15 7:51 ` Steve Graegert
2006-03-15 7:58 ` Per Jessen
2006-03-15 12:11 ` Steve Graegert
2006-03-15 7:59 ` Joel M. Pareja
2006-03-15 13:40 ` Vamsi
2006-03-15 8:16 ` Joel M. Pareja
2006-03-15 10:09 ` Glynn Clements
2006-03-15 15:48 ` Vamsi
2006-03-15 20:34 ` Tomas Janousek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).