Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

errors and casting

2 views
Skip to first unread message

Bill Cunningham

unread,
Apr 14, 2010, 8:16:05 PM4/14/10
to
I have honestly went over and over this and don't see the errors. In
memset's first parameter I even cast a void* and I don't like casts. I don't
know where the errors are from. I believe I have all the required posix
standard headers.

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/socket.h>

struct addrinfo a, *pa;

int stat;
void error(void)
{
fprintf(stderr, "Error: %d\n", errno);
exit(EXIT_FAILURE);
}

memset(&a,'\0',sizeof a);
a.ai_socket = SOCK_STREAM;
a.ai_family = AF_INET;
a.ai_flags = AI_PASSIVE;
17: error: syntax error before '&' token
error: conflicting types for 'memset'
error: conflicting types for 'memset'
warning: data definition has no type or storage class
18: error: syntax error before '.' token

That last error above has me baffled. I have written the error function so I
can call it when an error check proves there's an error.

Bill


jacob navia

unread,
Apr 14, 2010, 5:35:10 PM4/14/10
to
Bill Cunningham a écrit :

[snip]

The truth is that you were "studying sockets" six years ago in
comp.os.ms-windows.programmer.win32 and
microsoft.public.win32.programmer.ole, where you were asking Win32
programmers WinSock-flavoured versions of the questions that you are now
asking Unix programmers. Your postings would have the world think that
you have made zero progress in learning how to compile even basic C
programs in eight years, when you first started talking about how you
were using DJGPP and mingw. Indeed you are trying to convince people
that you have less grasp of things now than you did when you were
talking about recompiling gcc in comp.os.linux.development.apps in 2005,
or about the Standard C library in kernel-mode code in comp.lang.c back
in 2003, or about microkernels in comp.os.linux.development.system in
2002, or about how to use DJGPP in comp.os.linux in 2002, or about Win32
API programming in comp.programming in 2002.

More and more people are not going to fall for this any more. Jens
Thoms Toerring has sussed you. santosh and Mark McIntyre sussed you in
2005. They'll all no doubt be disappointed to learn that it took them
longer than Eric Tomson, who sussed you in 2002 when you asked Linus
Torvalds silly questions on the IETF mailing list.

Bill Cunningham

unread,
Apr 14, 2010, 5:36:21 PM4/14/10
to

"Bill Cunningham" <nos...@nspam.invalid> wrote in message
news:4bc6307e$0$12445

[...]

> memset(&a,'\0',sizeof a);
> a.ai_socket = SOCK_STREAM;
> a.ai_family = AF_INET;
> a.ai_flags = AI_PASSIVE;

OK if these need to be within a function please note I if I can don't
want them in a function. Maybe a header or .o file.

B


jacob navia

unread,
Apr 14, 2010, 5:39:34 PM4/14/10
to
Bill Cunningham a écrit :

The truth is that you were "studying sockets" six years ago in

Lew Pitcher

unread,
Apr 14, 2010, 5:45:31 PM4/14/10
to

Yes, Bill, those four statements *cannot* stand alone outside a function
body.

You are going to have to find a way to /put/ them within a function body
(your choice of /which/ function body) before your program will compile
properly.

--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me: http://pitcher.digitalfreehold.ca/ | Just Linux: http://justlinux.ca/
---------- Slackware - Because I know what I'm doing. ------


Keith Thompson

unread,
Apr 14, 2010, 6:01:29 PM4/14/10
to
"Bill Cunningham" <nos...@nspam.invalid> writes:
> I have honestly went over and over this and don't see the errors.
[snip]

All statements must be inside some function.

--
Keith Thompson (The_Other_Keith) 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"

Keith Thompson

unread,
Apr 14, 2010, 6:32:47 PM4/14/10
to

I was about to complain about your posting the above two paragraphs
(which you didn't originally write) without acknowledging the
author. Since the author happens to be someone who deliberately
snips attribution lines, I won't complain about that or identify
the author.

Neverthess, even he doesn't posted quoted text without indicating
that it's quoted text. The above looks just as it would if you,
jacob, had written it yourself; I only realized you hadn't because
I recognized that the writing isn't in your style. Apart from any
other reasons not to do this, it's confusing to your readers.

And you've posted the same thing at least three times in response
to Bill's posts. The point has been made. Please stop before you
exceed the Breidbart Index.

Nick Keighley

unread,
Apr 15, 2010, 3:29:54 AM4/15/10
to

try rewriting it in pascal then


io_x

unread,
Apr 15, 2010, 4:49:18 AM4/15/10
to

"Bill Cunningham" <nos...@nspam.invalid> ha scritto nel messaggio
news:4bc6307e$0$12445$bbae...@news.suddenlink.net...

> I have honestly went over and over this and don't see the errors.

if you can write so difficult english why have you some problem with C?

> In memset's first parameter I even cast a void* and I don't like casts. I
> don't know where the errors are from. I believe I have all the required posix
> standard headers.
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <errno.h>
> #include <string.h>
> #include <netdb.h>
> #include <sys/socket.h>
>
> struct addrinfo a, *pa;
>
> int stat;
> void error(void)
> {
> fprintf(stderr, "Error: %d\n", errno);
> exit(EXIT_FAILURE);
> }
>
> memset(&a,'\0',sizeof a);
> a.ai_socket = SOCK_STREAM;
> a.ai_family = AF_INET;
> a.ai_flags = AI_PASSIVE;

what does it mean "AI_PASSIVE?

Bill Cunningham

unread,
Apr 15, 2010, 7:45:31 AM4/15/10
to
io_x wrote:

> if you can write so difficult english why have you some problem with
> C?

[snip]

> what does it mean "AI_PASSIVE?

AI_PASSIVE is a pre-defined macro used in the posix networking standard
to allow getadrrinfo() to fill in the addrinfo struct with an IP address.
Wether that be IPv6 or IPv4.
http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html

Is a good place to read. Notice this is probably OT here and my question had
to do with ANSI C.

Bill


Bill Cunningham

unread,
Apr 15, 2010, 7:59:50 AM4/15/10
to
Lew Pitcher wrote:

> Yes, Bill, those four statements *cannot* stand alone outside a
> function body.
>
> You are going to have to find a way to /put/ them within a function
> body (your choice of /which/ function body) before your program will
> compile properly.

I was using code from
http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#bind

and these members are referred to not in a function. That's what got me.
They must've been written only as an example.

Bill


blm...@myrealbox.com

unread,
Apr 15, 2010, 8:20:05 AM4/15/10
to
In article <4bc6d0eb$0$1121$4faf...@reader3.news.tin.it>,

io_x <a...@b.c.invalid> wrote:
>
> "Bill Cunningham" <nos...@nspam.invalid> ha scritto nel messaggio
> news:4bc6307e$0$12445$bbae...@news.suddenlink.net...
> > I have honestly went over and over this and don't see the errors.
>
> if you can write so difficult english why have you some problem with C?

Picky speakers of English might point out that "I have went" is, um,
"incorrect"? "non-standard"?

Just sayin'.

I guess it might be interesting to know whether there's any correlation
between ability to learn a human language (particularly one learned as
a first language, as English presumably is for Bill C.) and ability to
to express algorithms in a programming language. But to me it doesn't
seem obvious that the first would necessarily imply the second.

[ snip ]

--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.

Bill Cunningham

unread,
Apr 15, 2010, 8:59:28 AM4/15/10
to

<blm...@myrealbox.com> wrote in message
news:82oejl...@mid.individual.net...

> Just sayin'.
>
> I guess it might be interesting to know whether there's any correlation
> between ability to learn a human language (particularly one learned as
> a first language, as English presumably is for Bill C.) and ability to
> to express algorithms in a programming language. But to me it doesn't
> seem obvious that the first would necessarily imply the second.

I don't like to say this much because I don't like to use it as an
excuse. But anyway I suffer from some nasty side effects from about 8
medications. They are getting ready to put me on addarall for fatigue and
attention deficit or ADD. So I have some trouble getting things finished and
focusing attention.

Just thought I'd say this.

Bill


Bill Cunningham

unread,
Apr 15, 2010, 9:04:27 AM4/15/10
to

"Bill Cunningham" <nos...@nspam.invalid> wrote in message
news:4bc70d98$0$12433

> I don't like to say this much because I don't like to use it as an
> excuse. But anyway I suffer from some nasty side effects from about 8
> medications. They are getting ready to put me on addarall for fatigue and
> attention deficit or ADD. So I have some trouble getting things finished
> and focusing attention.
>
> Just thought I'd say this.

And konopin casues me to not be able to concentrate. I am not able to
drive now because I can't remember where I'm going or how to get there. In a
town I've lived in all my life.

Bill


Message has been deleted

io_x

unread,
Apr 15, 2010, 10:00:13 AM4/15/10
to

<blm...@myrealbox.com> ha scritto nel messaggio
news:82oejl...@mid.individual.net...

> In article <4bc6d0eb$0$1121$4faf...@reader3.news.tin.it>,
> io_x <a...@b.c.invalid> wrote:
>>
>> "Bill Cunningham" <nos...@nspam.invalid> ha scritto nel messaggio
>> news:4bc6307e$0$12445$bbae...@news.suddenlink.net...
>> > I have honestly went over and over this and don't see the errors.
>>
>> if you can write so difficult english why have you some problem with C?
>
> Picky speakers of English might point out that "I have went" is, um,
> "incorrect"? "non-standard"?
>
> Just sayin'.
>
> I guess it might be interesting to know whether there's any correlation
> between ability to learn a human language (particularly one learned as
> a first language, as English presumably is for Bill C.) and ability to
> to express algorithms in a programming language. But to me it doesn't
> seem obvious that the first would necessarily imply the second.

yes i can make wrong if this is the case my excuse
but the "ability to write a human language" has many in common with
"one programming language"

Malcolm McLean

unread,
Apr 15, 2010, 9:55:09 AM4/15/10
to
On 15 Apr, 13:20, blm...@myrealbox.com <blm...@myrealbox.com> wrote:
>
> Picky speakers of English might point out that "I have went" is, um,
> "incorrect"?  "non-standard"?
>
Stigmatised. Adult speakers don't make grammatical errors in their
native language, almost by definition.

io_x

unread,
Apr 15, 2010, 5:25:15 PM4/15/10
to

"Malcolm McLean" ha scritto nel messaggio
news:bd1f34a1-0177-41b4...@v20g2000yqv.googlegroups.com...

i make grammatical errors in my native language too


Nick Keighley

unread,
Apr 16, 2010, 3:58:39 AM4/16/10
to
On 15 Apr, 14:55, Malcolm McLean <malcolm.mcle...@btinternet.com>
wrote:

I suspect only because you define "native language" as the language he
speaks grammatically as an adult.

blm...@myrealbox.com

unread,
Apr 16, 2010, 10:55:45 AM4/16/10
to
In article <4bc70d98$0$12433$bbae...@news.suddenlink.net>,

Just for the record .... I wasn't intending a put-down here, Bill,
just a nitpicky response to io_x's comment about English. You've
talked before about all those medications and their side effects.
It sounds pretty unpleasant, and I guess you have to cope as best
you can ....

J de Boyne Pollard

unread,
Apr 16, 2010, 1:49:01 PM4/16/10
to
> "Software development and writing are both
> the art of knowing what you're going to
> do, and then lucidly expressing your ideas."

Software development is more the art of knowing what the computer is
going to do. (-:

Joachim Pense

unread,
Apr 16, 2010, 6:14:34 PM4/16/10
to

I think that's not Software development, that's wizardry.

Joachim

Andrew Poelstra

unread,
Apr 16, 2010, 10:38:17 PM4/16/10
to

Isn't it both?

--
Andrew Poelstra
http://www.wpsoftware.net/andrew

Malcolm McLean

unread,
Apr 17, 2010, 2:53:53 AM4/17/10
to
On Apr 16, 8:58 am, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
Are the rules applied consistently (eg if he says "can't hardly" is it
always "can't hardly"), and are they accepted by at least one other
person (does someone else say "can't hardly")?

If so he's speaking grammatically.

Seebs

unread,
Apr 17, 2010, 2:58:16 AM4/17/10
to
On 2010-04-17, Malcolm McLean <malcolm...@btinternet.com> wrote:
> Are the rules applied consistently (eg if he says "can't hardly" is it
> always "can't hardly"), and are they accepted by at least one other
> person (does someone else say "can't hardly")?
>
> If so he's speaking grammatically.

This seems like it belongs in alt.usage.english.

I would say that, in general, if you assert that any speech according
to *a* grammar is grammatical, that reduces "grammatical" to the point
of near-irrelevance. In particular, it removes grammar from the list
of things a language has, because the existence of a pair of people who
use all the same words but don't use them in a way other people can
understand would render them perfectly "grammatical".

To bring this onto the general topic of C: The existence of a compiler
which accepts a particular program does not make that program "valid C".
What's usually at issue is whether we can have reasonable confidence
that C compilers in general would accept something, or even just a future
compiler from the same vendor.

Similarly, what's usually at issue with language is whether you have
reasonable confidence that an arbitrarily-selected native speaker of the
language you think you are speaking will be able to figure out how
to parse your sentences. If they can't, then if you are speaking
grammatically at all, you are speaking a different languauge than they
are hearing.

I tend to view "proper grammar" as rather a lot like "strictly conforming
C". It's not really required most of the time, but there is a HUGE advantage
to the writer in knowing what the rules are, even if the very next decision
you make is that you are going to break them.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

0 new messages