In message , Rami
Chowdhury wrote:
> I'm sorry, perhaps you've misunderstood what I was refuting. You posted:
>> >> macro:
>> >> #define Descr(v) &v, sizeof v
>> >>
>> >> As written, this works whatever the type of v: array, struct,
>> >> whatever.
>
> With my code example I found that, as
On Friday 02 July 2010 19:20:26 Lawrence D'Oliveiro wrote:
> In message , Rami
> Chowdhury wrote:
> > On Thursday 01 July 2010 16:50:59 Lawrence D'Oliveiro wrote:
> >> Nevertheless, it it at least self-consistent. To return to my original
> >>
> >> macro:
> >> #define Descr(v) &v, sizeof v
> >
In message , Rami
Chowdhury wrote:
> On Thursday 01 July 2010 16:50:59 Lawrence D'Oliveiro wrote:
>
>> Nevertheless, it it at least self-consistent. To return to my original
>> macro:
>>
>> #define Descr(v) &v, sizeof v
>>
>> As written, this works whatever the type of v: array, struct, wha
On Thursday 01 July 2010 16:50:59 Lawrence D'Oliveiro wrote:
> Nevertheless, it it at least self-consistent. To return to my original
> macro:
>
> #define Descr(v) &v, sizeof v
>
> As written, this works whatever the type of v: array, struct, whatever.
>
Doesn't seem to, sorry. Using Michae
In message <4c2ccd9c$0$1643$742ec...@news.sonic.net>, John Nagle wrote:
> The approach to arrays in C is just broken, for historical reasons.
Nevertheless, it it at least self-consistent. To return to my original
macro:
#define Descr(v) &v, sizeof v
As written, this works whatever the type
On 7/1/2010 8:36 AM, Mel wrote:
Nobody wrote:
On Wed, 30 Jun 2010 23:40:06 -0600, Michael Torrie wrote:
Given "char buf[512]", buf's type is char * according to the compiler
and every C textbook I know of.
References from Kernighan& Ritchie _The C Programming Language_ second
edition:
No,
On 07/01/2010 01:24 AM, Nobody wrote:
> No, the type of "buf" is "char [512]", i.e. "array of 512 chars". If you
> use "buf" as an rvalue (rather than an lvalue), it will be implicitly
> converted to char*.
Yes this is true. I misstated. I meant that most text books I've seen
say to just use the
Nobody wrote:
> On Wed, 30 Jun 2010 23:40:06 -0600, Michael Torrie wrote:
>> Given "char buf[512]", buf's type is char * according to the compiler
>> and every C textbook I know of.
References from Kernighan & Ritchie _The C Programming Language_ second
edition:
> No, the type of "buf" is "char
On Wed, 30 Jun 2010 23:40:06 -0600, Michael Torrie wrote:
> Given "char buf[512]", buf's type is char * according to the compiler
> and every C textbook I know of.
No, the type of "buf" is "char [512]", i.e. "array of 512 chars". If you
use "buf" as an rvalue (rather than an lvalue), it will be i
On Wed, 2010-06-30, Michael Torrie wrote:
> On 06/30/2010 03:00 AM, Jorgen Grahn wrote:
>> On Wed, 2010-06-30, Michael Torrie wrote:
>>> On 06/29/2010 10:17 PM, Michael Torrie wrote:
On 06/29/2010 10:05 PM, Michael Torrie wrote:
> #include
>
> int main(int argc, char ** argv)
On 06/30/2010 06:36 PM, Lawrence D'Oliveiro wrote:
> In message ,
> Michael Torrie wrote:
>
>> Okay, I will. Your code passes a char** when a char* is expected.
>
> No it doesn’t.
You're right; it doesn't. Your code passes char (*)[512].
warning: passing argument 1 of ‘snprintf’ from incompati
In message , Michael
Torrie wrote:
> Okay, I will. Your code passes a char** when a char* is expected.
No it doesn’t.
> Consider this variation where I use a dynamically allocated buffer
> instead of static:
And so you misunderstand the difference between a C array and a pointer.
--
http://ma
On 06/30/2010 03:00 AM, Jorgen Grahn wrote:
> On Wed, 2010-06-30, Michael Torrie wrote:
>> On 06/29/2010 10:17 PM, Michael Torrie wrote:
>>> On 06/29/2010 10:05 PM, Michael Torrie wrote:
#include
int main(int argc, char ** argv)
{
char *buf = malloc(512 * sizeof(char));
On Wed, 2010-06-30, Michael Torrie wrote:
> On 06/29/2010 10:17 PM, Michael Torrie wrote:
>> On 06/29/2010 10:05 PM, Michael Torrie wrote:
>>> #include
>>>
>>> int main(int argc, char ** argv)
>>> {
>>> char *buf = malloc(512 * sizeof(char));
>>> const int a = 2, b = 3;
>>> snprintf(&b
On 06/29/2010 10:17 PM, Michael Torrie wrote:
> On 06/29/2010 10:05 PM, Michael Torrie wrote:
>> #include
>>
>> int main(int argc, char ** argv)
>> {
>> char *buf = malloc(512 * sizeof(char));
>> const int a = 2, b = 3;
>> snprintf(&buf, sizeof buf, "%d + %d = %d\n", a, b, a + b);
>
On 06/29/2010 10:05 PM, Michael Torrie wrote:
> #include
>
> int main(int argc, char ** argv)
> {
> char *buf = malloc(512 * sizeof(char));
> const int a = 2, b = 3;
> snprintf(&buf, sizeof buf, "%d + %d = %d\n", a, b, a + b);
^^
Make that 512*size
On 06/29/2010 06:25 PM, Lawrence D'Oliveiro wrote:
> I have yet to find an architecture or C compiler where it DOESN’T work.
>
> Feel free to try and prove me wrong.
Okay, I will. Your code passes a char** when a char* is expected. Every
compiler I know of will give you a *warning*. Mistaking c
In message , Kushal
Kumaran wrote:
> On Tue, Jun 29, 2010 at 5:56 AM, Lawrence D'Oliveiro
> wrote:
>
>> Why does this work, then:
>>
>> l...@theon:hack> cat test.c
>> #include
>>
>> int main(int argc, char ** argv)
>> {
>>char buf[512];
>>const int a = 2, b = 3;
>>snprintf(&buf, si
On Tue, Jun 29, 2010 at 5:56 AM, Lawrence D'Oliveiro
wrote:
> In message , Kushal
> Kumaran wrote:
>
>> On Sun, Jun 27, 2010 at 5:16 PM, Lawrence D'Oliveiro
>> wrote:
>>
>>>In message , Kushal
>>> Kumaran wrote:
>>>
On Sun, Jun 27, 2010 at 9:47 AM, Lawrence D'Oliveiro
wrote:
>
In message , Kushal
Kumaran wrote:
> On Sun, Jun 27, 2010 at 5:16 PM, Lawrence D'Oliveiro
> wrote:
>
>>In message , Kushal
>> Kumaran wrote:
>>
>>> On Sun, Jun 27, 2010 at 9:47 AM, Lawrence D'Oliveiro
>>> wrote:
>>>
A long while ago I came up with this macro:
#define Descr(v) &v,
On Sun, Jun 27, 2010 at 5:16 PM, Lawrence D'Oliveiro
wrote:
> In message , Kushal
> Kumaran wrote:
>
>> On Sun, Jun 27, 2010 at 9:47 AM, Lawrence D'Oliveiro
>> wrote:
>>
>>> In message , Roy Smith wrote:
>>>
I recently fixed a bug in some production code. The programmer was
careful to
21 matches
Mail list logo