C call of a C# dll

E

Eltee

Keith said:
Yes, there is such a language as C. There are also a number of C-like
dialects. We discuss the former, not the latter.

Then, to avoid confusion, you should rename your (sic!) NG
comp.lang.pure.c, comp.lang.1990iso.c, comp.lang.1999iso.c or
comp.lang.kr.c. ;-) Otherwise guys like me will bother you with OT
questions all the time. Seriously, would you "reject" some C-related
quesion only because the code snippet illustrating the problem used some
"third party" lib?
We discuss C as defined by the 1990 and 1999 ISO standards, and
sometimes historical versions of C a defined by K&R1 and earlier
documents. We find that these restrictions don't create any lack of
things to talk about, as you can tell from the high volume of this
newsgroup.

[snip]
Right, silly me. BTW: are you guys always so helpful or are you just
trying to be elitistic?


If someone has a question about standard C, we tend to be very
helpful. For questions about anything else, the best help we can give
is to advise the questioner to ask it somewhere else.

That's all I need. But, as you can see, I got something completely
different from Martin. Thrice. Only infobahn (thanks again!) gave me
some decent advice.
 
E

Eltee

Mark said:
There's exacly one computer langauge called C. Its defined by the ISO
standard.




Guess.

The one defined by the ISO standard?
We're always so helpful. It only looks elitist if you're too stupid to
realise you're asking about buying socks in a greengrocers.

Could be. Could be. Then again such problems can easily be solved. All
it takes is a little smile from the greengrocery attendant and a
direction to a socks shop instead of a (c)rude "we don't sell socks and
we especially don't sell Gatessocks!".
Round here, we agressively defend teh topic of the group, because otherwise
it gets filled with people asking offtopic quesstions, and idiots answering
them with incorrect, misleading or plain bollocks answers.




I have no clue. Get a newsreader with search facilities.




C has no flavours. And there's a U in flavour.

You're absolutely right. There's a U in colour, too. If you ask the
right people. Others will, of course, deny it. ;-) Me, sometimes I use
it and sometimes I don't. Depends on the mood I'm in and on the
spell-link chequer I use (if I use one at all). ;-)
 
K

Keith Thompson

Eltee said:
Then, to avoid confusion, you should rename your (sic!) NG
comp.lang.pure.c, comp.lang.1990iso.c, comp.lang.1999iso.c or
comp.lang.kr.c. ;-) Otherwise guys like me will bother you with OT
questions all the time.

Guys like you do bother us with OT questions all the time. Most of
them have sense enough to pay attention when we tell them their
questions are off-topic.

The scope of the newsgroup isn't entirely obvious from its name. But
now you know. What exactly are you hoping to accomplish by belaboring
the point?
Seriously, would you "reject" some C-related quesion only because
the code snippet illustrating the problem used some "third party"
lib?

It depends on the circumstances.
 
L

Lawrence Kirby

Then, to avoid confusion, you should rename your (sic!) NG
comp.lang.pure.c, comp.lang.1990iso.c, comp.lang.1999iso.c or
comp.lang.kr.c. ;-) Otherwise guys like me will bother you with OT
questions all the time.

Believe me that will happen anyway. :)

Besides you now know what the C language is, so this isn't all bad. This
newsgroup IS about the C language so comp.lang.c is a good name for it and
akes it broadly consistent with other language newsgroups.
Seriously, would you "reject" some C-related
quesion only because the code snippet illustrating the problem used some
"third party" lib?

It depends on whether the problem is about issues with C or issues with
the 3rd party lib. For example there is a problem with the code:

execl("name", NULL);

To see that there's a problem you have to know that this is the POSIX
function (C doesn't define it), and that the POSIX execl() takes a
variable argument list of character pointers (the last of which must be a
null pointer). Once you know that the problem itself is entirely a C one.

Not everybody replying may spot that however, nor should they be expected
to.

Lawrence
 
C

CBFalconer

Eltee said:
Mark McIntyre wrote:
.... snip ...

Could be. Could be. Then again such problems can easily be
solved. All it takes is a little smile from the greengrocery
attendant and a direction to a socks shop instead of a (c)rude
"we don't sell socks and we especially don't sell Gatessocks!".

Meanwhile, by ignoring perfectly sound, if terse, advice you have
accomplished getting yourself listed in various PLONK lists, so
that when and if you ever really need advice in this field you just
won't be heard. You'll go far.
 
C

Charlie Gordon

It depends on whether the problem is about issues with C or issues with
the 3rd party lib. For example there is a problem with the code:

execl("name", NULL);

To see that there's a problem you have to know that this is the POSIX
function (C doesn't define it), and that the POSIX execl() takes a
variable argument list of character pointers (the last of which must be a
null pointer). Once you know that the problem itself is entirely a C one.

Not everybody replying may spot that however, nor should they be expected
to.

If we provide the propotype for the execl function, a discussion on what
problems lie in the example is very much on topic:

from the Linux man page:

int execl( const char *path, const char *arg, ...);

In the example given, there really are 2 kinds of problems, one related to the
semantics of the execl() library function and system call, that specifies that
the first argument to execl is the pathname of a file to be executed, the second
and subsequent being a list of the arguments passed to that command as argv[0],
argv[1]... upto and including a NULL argument acting as a terminator.

execl("name", NULL);

will try and execute a file called "name" in the current directory, giving it a
NULL argv[0] and will scan extra arguments for NULL, invoking undefined
behaviour as no extra arguments were supplied.

Correcting this, and assuming "name" is indeed in the current directory, we
would get:

execl("name", "name", NULL);

However, there still is a problem with this piece of C code : passing NULL to un
unprototyped function or one with a variable list of arguments may not have the
intended effect : NULL can be defined as 0, and thus would be passed as an 'int'
instead of a 'const char*' possibly of different size, and the alternative
definition of NULL as ((void*)0) would also fail to pass the pointer correctly
on weird architectures where all pointer types do not have the same encoding.
One can correct this as:

execl("name", "name", (char*)NULL);
 
R

Richard Bos

Eltee said:
Then, to avoid confusion, you should rename your (sic!) NG
comp.lang.pure.c, comp.lang.1990iso.c, comp.lang.1999iso.c or
comp.lang.kr.c. ;-)

That's a very old joke. It wasn't funny the first time, either. Why
should one of the oldest groups on Usenet change its policies merely
because some newbies are too arrogant or too stupid to understand
netiquette and read the welcome message?
Otherwise guys like me will bother you with OT
questions all the time. Seriously, would you "reject" some C-related
quesion only because the code snippet illustrating the problem used some
"third party" lib?

Depends. If the problem is, or could easily be, due to the third party
lib, yes. If the lib is completely external to the problem, no.

In your case, your use of not only OS-specific features, but even
completely unrelated languages, was absolutely central to the problem.
This means that your question belongs somewhere that DLLs and dot
com^Hnet are on topic, which isn't here.

Richard
 
E

Eltee

CBFalconer said:
... snip ...



Meanwhile, by ignoring perfectly sound, if terse, advice you have
accomplished getting yourself listed in various PLONK lists, so
that when and if you ever really need advice in this field you just
won't be heard. You'll go far.

Oh, yeah, I forgot that one: greengrocery attendant could hire a bouncer
with strict instructions not to let me in again.

Thanks, CB, I feel more welcome in this NG every day.
 
E

Eltee

Richard said:
That's a very old joke. It wasn't funny the first time, either.

Oh, well, not all jokes are funny to all people.
> Why
should one of the oldest groups on Usenet change its policies merely
because some newbies are too arrogant or too stupid to understand
netiquette and read the welcome message?

Welcome message? What? Where? How?
 
L

Lawrence Kirby

If we provide the propotype for the execl function, a discussion on what
problems lie in the example is very much on topic:

Yes, if whoever asked a question did that then great. However even if they
didn't do that I'd still answer the question if I knew it has a standard
C answer.
from the Linux man page:

int execl( const char *path, const char *arg, ...);

In the example given, there really are 2 kinds of problems, one related
to the semantics of the execl() library function and system call, that
specifies that the first argument to execl is the pathname of a file to
be executed, the second and subsequent being a list of the arguments
passed to that command as argv[0], argv[1]... upto and including a NULL
argument acting as a terminator.

execl("name", NULL);

will try and execute a file called "name" in the current directory,
giving it a NULL argv[0] and will scan extra arguments for NULL,
invoking undefined behaviour as no extra arguments were supplied.

That isn't a problem for the POSIX execl() function in the sense that

execl("name", (const char *)NULL);

is perfectly valid, if a little odd. If it succeeds it even causes the new
program to be invoked in a conforming way. The null pointer as the second
argument is valid as a terminator for the argument list. Look at the
declaration above for execl(), it is compatible with 2 or more arguments,
just not with 1 or 0 arguments. If "name" refers to an application built
from C code it is valid for the implementation to call main() in it with
argc==0.
Correcting this, and assuming "name" is indeed in the current directory,
we would get:

execl("name", "name", NULL);

That is more normal (barring the issue below) but does't make the two
argument version invalid.
However, there still is a problem with this piece of C code : passing
NULL to un unprototyped function or one with a variable list of
arguments may not have the intended effect : NULL can be defined as 0,
and thus would be passed as an 'int' instead of a 'const char*' possibly
of different size, and the alternative definition of NULL as ((void*)0)
would also fail to pass the pointer correctly on weird architectures
where all pointer types do not have the same encoding. One can correct
this as:

That's less clear. void * is required to have the same representation as
pointers to character types. But you are correct in the more general case.

This is of course the C issue I was referring to in my original post. The
issue about whether the 2nd argument can be null shows the risk of
discussing non-standard code, it can easily move to a discussion of the
non-standard parts. We just have to try to avoid that but it can be tricky.

Lawrence
 
I

infobahn

Eltee said:
Thanks, CB, I feel more welcome in this NG every day.

I'm doing the best I can to make you feel as welcome
as I can, but it's not getting any easier.

As another poster pointed out, you will get better
help from this newsgroup on strictly C-related
issues (when you need such help) if you don't make
a boatload of enemies right now.

You're not going to change their minds, believe me
(many have tried and failed), so it might be better
to cut your losses and move on. I don't mean "stop
using this newsgroup"; I just mean that you're onto
a loser and, being a wise chap, you ought to know
when to stop bashing your head against the wall. :)

When you have a real C question, I hope you'll agree
that you'll get no better help than in this newsgroup.
These guys really are the best at what they do, and
it would be sad if you cut yourself off from their
help for such a silly reason.

Good luck with your C# thing.
 
I

infobahn

Eltee said:
Thanks, CB, I feel more welcome in this NG every day.

I'm doing the best I can to make you feel as welcome
as I can, but it's not getting any easier.

As another poster pointed out, you will get better
help from this newsgroup on strictly C-related
issues (when you need such help) if you don't make
a boatload of enemies right now.

You're not going to change their minds, believe me
(many have tried and failed), so it might be better
to cut your losses and move on. I don't mean "stop
using this newsgroup"; I just mean that you're onto
a loser and, being a wise chap, you ought to know
when to stop bashing your head against the wall. :)

When you have a real C question, I hope you'll agree
that you'll get no better help than in this newsgroup.
These guys really are the best at what they do, and
it would be sad if you cut yourself off from their
help for such a silly reason.

Good luck with your C# thing.
 
C

CBFalconer

Eltee said:
CBFalconer wrote:
.... snip ...

Oh, yeah, I forgot that one: greengrocery attendant could hire a
bouncer with strict instructions not to let me in again.

Thanks, CB, I feel more welcome in this NG every day.

That's bad. Lacking reformation, we would prefer you go away and
harass someone else.
 
W

William Ahern

Then, to avoid confusion, you should rename your (sic!) NG
comp.lang.pure.c, comp.lang.1990iso.c, comp.lang.1999iso.c or
comp.lang.kr.c. ;-)

FWIW, this newsgroup was around long before "1999iso" and "1999iso". And it
seems many of the same people are around as well. And I, for one, am
thankful that this place has been diligently maintained as such a unique
forum.

Anyhow, it makes absolutely no sense to ask nor argue questions about
esoteric Windows functionality and interfaces. At the very least it
distracts from those asking pertinent questions about "common" C. At the
worst you'll get all kinds of poor, misleading or downright wrong answers.
Some of the people here, including myself, haven't touched a Windows
computer (let alone code) in years. You need strong peer review to keep
everybody sharp.

You should be thankful that in comp.lang.c the name is interpreted narrowly
and not broadly (your way isn't the only way, and if you put some thought
into it...). I can guarantee that there'll be more than a few times where
you'll find comp.lang.c the best, if not only, place to ask a particular C
question. I hope next time you'll have the sense and graciousness to utilize
it properly.
Otherwise guys like me will bother you with OT questions all the
time.Seriously, would you "reject" some C-related quesion only because the
code snippet illustrating the problem used some "third party" lib?

C# is hardly a "third party C library". Such a question might be answered if
the snippet clearly illustrated a mistake in the C syntax or misuse of a C
construct. Of course, it would help if the poster included an interface
definition of the library. But, as you can see, it quickly becomes a
slippery slope. Would you mind describing in a thousand pages or less C# for
the rest of us so we could answer your question(s)? I would hope you would
mind.

Think before you step.
 
M

Malcolm

Eltee said:
That's all I need. But, as you can see, I got something completely
different from Martin. Thrice. Only infobahn (thanks again!) gave me
some decent advice.
In my view questions about "how do I call language x from language y" so go
in an ng devoted to language y. So you are actually on topic.
Some people might take the view that these questions belong in the group
devoted to the newer language.
However there is not much help we can offer on how to call C sharp from C.
The standard itself offers no facilities beyond the ability to link objects
defined with "C linkage". However Mr Gates may well have provided some
extensions. I genuinely don't know about this - I do write under Windows but
not programs that make heavy use of OS-specific resources.
 
M

Martin Ambuhl

Eltee said:
Keith Thompson wrote:


That's all I need. But, as you can see, I got something completely
different from Martin.

False. Telling you this is not the place to ask is, except to the
terminal dense, telling you that you need to ask elsewhere.

You can't count. Only two messages were responses to your posts, and
those were to two different posts by you.
message 1) in response to your original off-topic question
message 2) in response to the person answering your off-topic
question with an off-topic answer. BTW, you might
consider whether you could trust his answer. He sent me
an email claiming not to be able to tell that you had
cross-posted to comp.lang.c. This suggests incompetence
on his part.
message 3) in response to your off-topic request that he expand on his
off-topic answer to your off-topic question.
 
C

CBFalconer

Malcolm said:
.... snip eltee annoyances ...

In my view questions about "how do I call language x from language y"
so go in an ng devoted to language y. So you are actually on topic.

No, the question is actually "how do I call language x from
language y when running on system z", and belongs in a group
devoted to system z and all its peculiarities.
 
K

Keith Thompson

CBFalconer said:
No, the question is actually "how do I call language x from
language y when running on system z", and belongs in a group
devoted to system z and all its peculiarities.

The group where the question is topical depends on x, y, and z.

For example, "How do I call C from C++" is topical in comp.lang.c++;
the answer is to use 'extern "C"' (I think that's right). "How do I
call C from Ada" is topical in comp.lang.ada; the answer is to use
Ada's pragma Import(C,...). "How do I call Ada from C" is also
topical in comp.lang.ada; the answer is to use Ada's
pragma Export(C, ...).

If you don't know how to call language x from language y, it's
probably not unreasonable to ask in either comp.lang.x or comp.lang.y
(preferably after doing a little research). If x==c, you're likely to
be directed elsewhere; that's fine as long as you don't insist on
dragging out the discussion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top