473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

read image from url

Hi, can anyone point me a library that can read image to memory from a
URL? It is very easy in Java, but it is hard to find an complete
solution in c/c++.

Thanks,

Jul 3 '06
92 9204
Old Wolf posted:
Well, I would if you would actually provide a valid email address,
or perhaps suggest some other forum where you would like to
discuss the matter.

Perhaps you misinterpreted me; I do not wish to discuss the topic. I
apologise for any inconvenience this causes you.

However I look forward to discussing computer programming with you, both
here and over on comp.lang.c.

I do not provide a valid e-mail address when posting on Usenet as I do not
wish to receive communications via e-mail. Programming can be discussed
right here, and participants need not contact me personally unless they
intend to discuss a topic orthogonal to programming. Given that I do not
wish to discuss a topic orthogonal to programming with the participants on
this newsgroup, I elect not to provide an extraneous means of
communication.

I hope you understand my choice.

--

Frederick Gotham
Jul 5 '06 #51
Old Wolf said:

<snip>
Note for killfilers: this is the same person as "JKop" and "Tomas".
(a) so what?
(b) you might be wrong.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 5 '06 #52
[Followups set to comp.lang.c]

Mark McIntyre said:
On Tue, 04 Jul 2006 15:25:34 GMT, in comp.lang.c , Frederick Gotham
<fg*******@SPAM.comwrote:
>>
How about I disregard everything you say -- yes, I like that.

Smart move.

Welcome to the killfile of about half the regulars here.

The rest will be watching specially for your posts, so they can
correct the schoolboy errors.
He hasn't made that many schoolboy errors, actually. In fact, the worst
error he's made so far that I can recall is this one - i.e. describing the
differences between C and C++ as "minor". And the second-worst is in
picking a fight with Martin Ambuhl.

In fact, Frederick Gotham does seem rather bellicose all round, which
(together with his fondness for dragging C++ comparisons into C discussions
in a C newsgroup) is a bit of a shame, since he otherwise seems like quite
a reasonable fellow.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 5 '06 #53
Richard Heathfield wrote:
>Note for killfilers: this is the same person as "JKop" and "Tomas".

(a) so what?
(b) you might be wrong.
If someone's going to troll, changing their name gets only a brief respite
from the kill-files. Then their habits come out again, and they go in the
kill-files again. No biggie.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jul 5 '06 #54
Phlip said:
Richard Heathfield wrote:
>>Note for killfilers: this is the same person as "JKop" and "Tomas".

(a) so what?
(b) you might be wrong.

If someone's going to troll, changing their name gets only a brief respite
from the kill-files. Then their habits come out again, and they go in the
kill-files again. No biggie.
Yes, where rational people are concerned, it's the /behaviour/ that is being
killfiled, not the person. If someone wishes to ameliorate their behaviour,
a quick ID change may well help facilitate that and enable them to have
meaningful interactions with people in whose killfiles they would otherwise
have rotted. In cases where former trolls are attempting to rehabilitate
themselves under a new name and we happen to notice (e.g. through some
trick of consistent misspelling or whatever), it may be more constructive
to pretend we didn't.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 5 '06 #55

qu******@yahoo.com wrote:
Hi, can anyone point me a library that can read image to memory from a
URL? It is very easy in Java, but it is hard to find an complete
solution in c/c++.

Thanks,
You could try the magick++ library. This lets you read a variety of
image formats from a url into memory and provides lots of functions to
manipulate and export.

http://www.imagemagick.org/

Hope this reply is more useful than some of the others you have had :)

Rob

Jul 5 '06 #56
Richard Heathfield wrote:
Yes, where rational people are concerned, it's the /behaviour/ that is
being
killfiled, not the person. If someone wishes to ameliorate their
behaviour,
a quick ID change may well help facilitate that and enable them to have
meaningful interactions with people in whose killfiles they would
otherwise
have rotted. In cases where former trolls are attempting to rehabilitate
themselves under a new name and we happen to notice (e.g. through some
trick of consistent misspelling or whatever), it may be more constructive
to pretend we didn't.
And when they change their name to "Troll4", just to say "hah hah - you
can't resist me!", then it might just be less constructive...

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jul 5 '06 #57
In comp.lang.c jacob <ja***@jacob.remcomp.frwrote:
This people are NOT representative of this group nor of the
majority of C users.
I personally find that to be unfortunate.

--
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.
Jul 5 '06 #58
Murali Krishna wrote:
That's a lengthy discussion with no particular reason.

What is there in saying C/C++ and C or C++? I don't want to start an
argument. If you can understand what other's want to say, that's
enough. You are brilliant.
If you/rapist want to discuss/whine the usage/idiotacy of
how a slash is interpreted, think/whine about how it
would work/smell in normal English/pornography.

Using a slash in order to save a couple of letters of typing
doesn't improve the ability to communicate; doesn't make your
meaning clear; and it doesn't save any typing, because you
have to deal with the flame-war that it generates.
I think Frederick is with the person who started the thread. Funniest
thing is that he is asking Fred to go away.
I think the funniest thing so far is: C and C++ are the same,
as long as you ignore the differences.

English and Russian are also the same, as long as you ignore
the differences.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 5 '06 #59
Frederick Gotham wrote:
Ian Collins posted:

>>qu******@yahoo.com wrote:
>>>Hi, can anyone point me a library that can read image to memory from
a URL? It is very easy in Java, but it is hard to find an complete
solution in c/c++.

Maybe because the mythical language of C/C++ doesn't exit?

The 5 consecutive characters, "C/C++", refer to "C or C++".
If you/complete-moron believe that, than you/poser
should not take any offense at this message.
If I were to write a program which didn't use the extended features which
C++ provides over C, then I'd call it a C program.
Then why are you insisting on calling it a "C or C++" program?

You could also call it a C/Cobal or a Fortran/C program,
using your definition of '/'.
Makes me think of how race car manufacturers try to get a "road
worthiness stamp" for their race vehicles; these vehicles are primarily
race vehicles, not road vehicles, but if they can get a road-worthiness
stamp for it aswell, then that's great!
Why, you could try to call your code a C/Java program to see
if you could increase its marketability.
>
If you start off writing a program with no intention of prohibiting
yourself from using C++ features, and still end up with a finished
product which doesn't use C++ features, then it's quite like setting out
to design a race car, and ending up with a car that's also road-worthy.
If you start out to write a C++ program, but end up with
something that compiles with a Cobal compiler, would you
still call it C++?
I compare the ability to "compile as C" with a "road worthiness stamp" --
it's the icing on the cake!
Add more icing and make it compile under Fortran.
That could also be a "road worthiness stamp".
I *never* hesitate to use C++ features, (and I actually use them quite
often), but if I did some day produce a program which didn't use any C++
features at all, I'd consider going back through it and changing
everything to C.
If it doesn't use "C++ features", as they have been called in
this discussion, than what would you be changing to make it "C"
If you're after versatility, it's better to have C code than C++ code.
And for even more versitility, advertise it as
C/Cobal/Basic/Perl/Python/Awk/Sed/Bliss/Intercal/Fortran/Pascal/C++
code (remember, '/' means 'or').

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 5 '06 #60
Phlip said:
Richard Heathfield wrote:
<snip>
>In cases where former trolls are attempting to rehabilitate
themselves under a new name and we happen to notice (e.g. through some
trick of consistent misspelling or whatever), it may be more constructive
to pretend we didn't.

And when they change their name to "Troll4", just to say "hah hah - you
can't resist me!", then it might just be less constructive...
That doesn't appear to be relevant in this case, however.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 5 '06 #61
On Wed, 05 Jul 2006 01:00:02 +0200, in comp.lang.c , Kai-Uwe Bux
<jk********@gmx.netwrote:
>Mark McIntyre wrote:
>Actually, it was probably because you made an idiotic remark. The fix
is probably to avoid emitting asinine comments, like these...

I would conjecture that it was because Martin Ambuhl and you ignored the
clause "if you take out C++ extensions".
I guess I ignored it because it was as idiotic as the rest of the
remark.

Fortran is pretty much like French, if you take out the Fortran
extensions.
>different handling of recursion,

could you elaborate on this one
main.
>exception handling,

Isn't that a C++ extension?
It can't be an extension to C++ since its part of the C++ standard.
>different IO routines,

The stream IO, I would consider an extension. What are the huge (not minor)
differences between C and C++ with regard to the printf family?
Whats the effect of << in C?
>different memory management routines,

new/delete is an extension. What are the big differences in malloc/free
between C and C++?
This is a C FAQ.

BTW I forgot to mention operator overload.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 5 '06 #62
jacob wrote:
Martin Ambuhl wrote:
>Frederick Gotham wrote:
Why be pedantic man?

It is OBVIOUS TO MOST PEOPLE (besides the pedantic ones) what the
original poster wanted.
Just a newbie question: If you are writing a C++ programm and need some
function to do some stuff (as the OP), is it ok to use a C function
which you found somewhere on the web in your code?

Or is there such a thing as a "rule" which stipulates that you would
_have_ to rewrite the code using C++ ideas?
(sounds pretty stupid to me if you are applying the rules of the FAQ
saying that main factors are time, money and risk
(http://www.parashift.com/c++-faq-lit....html#faq-6.17)

Phil
Jul 6 '06 #63
Philipp wrote:
jacob wrote:
>Martin Ambuhl wrote:
>>Frederick Gotham wrote:

Why be pedantic man?

It is OBVIOUS TO MOST PEOPLE (besides the pedantic ones) what the
original poster wanted.


Just a newbie question: If you are writing a C++ programm and need some
function to do some stuff (as the OP), is it ok to use a C function
which you found somewhere on the web in your code?
Yes. The only issues are going the other way.

--
Ian Collins.
Jul 6 '06 #64
Ian Collins wrote:
Philipp wrote:
>jacob wrote:
>>Martin Ambuhl wrote:

Frederick Gotham wrote:
Why be pedantic man?

It is OBVIOUS TO MOST PEOPLE (besides the pedantic ones) what the
original poster wanted.

Just a newbie question: If you are writing a C++ programm and need some
function to do some stuff (as the OP), is it ok to use a C function
which you found somewhere on the web in your code?
Yes. The only issues are going the other way.
So what's so wrong from the OP about asking for a piece of code in
(either) C or C++ to do some stuff?

(He's not implying that C or C++ are the same (or even similar). He's
just saying, "both will work for me").

PS: Or is the real problem that one should write "C or C++" instead of
"C/C++" ? (come on...)

Jul 6 '06 #65
Philipp wrote:
Ian Collins wrote:
>Philipp wrote:
>>jacob wrote:

Martin Ambuhl wrote:

Frederick Gotham wrote:

Why be pedantic man?

It is OBVIOUS TO MOST PEOPLE (besides the pedantic ones) what the
original poster wanted.
Just a newbie question: If you are writing a C++ programm and need some
function to do some stuff (as the OP), is it ok to use a C function
which you found somewhere on the web in your code?
Yes. The only issues are going the other way.

So what's so wrong from the OP about asking for a piece of code in
(either) C or C++ to do some stuff?

(He's not implying that C or C++ are the same (or even similar). He's
just saying, "both will work for me").

PS: Or is the real problem that one should write "C or C++" instead of
"C/C++" ? (come on...)
Well, that is precisely what I meant when I said that there were "minor"
differences. You can use any C function in C++ by qualifying it as
extern "C", and that is it, you can use it as you want!

All the insults, flames, etc can't hide this simple fact.
Jul 6 '06 #66
jacob navia posted:
You can use any C function in C++ by qualifying it as extern "C", and
that is it, you can use it as you want!
Must every C++ compiler provide a facility for compiling C code? Can the
following program be considered universally portable?

/* stuff.c */

#include <stddef.h>
#include <stdlib.h>

char *AllocCharArray( size_t const len )
{
return malloc(len);
}
/* main.cpp */

#include <cstdlib>

extern "C" { char *AllocCharArray( std::size_t const len ); }

int main()
{
char * const p = AllocCharArray(64);

std::free(p);
}
--

Frederick Gotham
Jul 6 '06 #67
TB
jacob navia skrev:
Philipp wrote:
>Ian Collins wrote:
>>Philipp wrote:

jacob wrote:

Martin Ambuhl wrote:
>
>Frederick Gotham wrote:
>
Why be pedantic man?
>
It is OBVIOUS TO MOST PEOPLE (besides the pedantic ones) what the
original poster wanted.
Just a newbie question: If you are writing a C++ programm and need some
function to do some stuff (as the OP), is it ok to use a C function
which you found somewhere on the web in your code?

Yes. The only issues are going the other way.

So what's so wrong from the OP about asking for a piece of code in
(either) C or C++ to do some stuff?

(He's not implying that C or C++ are the same (or even similar). He's
just saying, "both will work for me").

PS: Or is the real problem that one should write "C or C++" instead of
"C/C++" ? (come on...)

Well, that is precisely what I meant when I said that there were "minor"
differences. You can use any C function in C++ by qualifying it as
extern "C", and that is it, you can use it as you want!

All the insults, flames, etc can't hide this simple fact.
extern "C" {
void foo(int * restrict, int * restrict) {}
void bar(int n, int a[static 5][n + 1]) {
int v[a[4][n]];
}
}

--
TB @ SWEDEN
Jul 6 '06 #68
On Thu, 06 Jul 2006 11:07:57 +0200, in comp.lang.c , Philipp
<si*******@freesurf.chwrote:
>Ian Collins wrote:
>Philipp wrote:
>>Just a newbie question: If you are writing a C++ programm and need some
function to do some stuff (as the OP), is it ok to use a C function
which you found somewhere on the web in your code?
Yes. The only issues are going the other way.

So what's so wrong from the OP about asking for a piece of code in
(either) C or C++ to do some stuff?
If he'd done that, there'd be no problems though the C solution might
have been inappropriate or inefficient or potentially just plain
incorrect in C++. F'rinstance a C solution wouldn't cast the return
from malloc, and might use sizeof('a'). It might be more eficient to
use a container of some sort.

What he instead asked for was a solution in the mythical language
C/C++.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 6 '06 #69
On Thu, 06 Jul 2006 13:14:21 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
You can use any C function in C++ by qualifying it as
extern "C", and that is it, you can use it as you want!
This is completely wrong.
>All the insults, flames, etc can't hide this simple fact.
Perhaps once you've actually tried this properly, you'll be able to
post a correction.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 6 '06 #70
Mark McIntyre wrote:
On Thu, 06 Jul 2006 13:14:21 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:

>>You can use any C function in C++ by qualifying it as
extern "C", and that is it, you can use it as you want!


This is completely wrong.
Sorry if I'm confused.
in FAQ http://www.parashift.com/c++-faq-lit....html#faq-32.5
it says that "you can declare the individual C function in your C++ code
using the extern "C" syntax"

Is this wrong? (!)
Jul 6 '06 #71
On Thu, 06 Jul 2006 17:43:59 +0200, Philipp <si*******@freesurf.ch>
wrote:
>Mark McIntyre wrote:
>On Thu, 06 Jul 2006 13:14:21 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:

>>>You can use any C function in C++ by qualifying it as
extern "C", and that is it, you can use it as you want!


This is completely wrong.

Sorry if I'm confused.
in FAQ http://www.parashift.com/c++-faq-lit....html#faq-32.5
it says that "you can declare the individual C function in your C++ code
using the extern "C" syntax"

Is this wrong? (!)
"Declare" is not the same as "use." The "extern C" wrapper just
disables name mangling, so that the function is called with it's
proper name. It doesn't magically make non-C code C++ compatible.

Normally, the way this is used is that you have a C function (perhaps
in a library) which has been compiled by a C compiler. You want to
call this function from a C++ program. If you declare it in the normal
way, the compiler will transform ("mangle") the name by adding
information about the parameter types, for example. The name generated
won't match the name of the C function, and the linker won't be able
to find it. If you declare the function using "extern C", the C++
compiler will leave the name as is.

--
Al Balmer
Sun City, AZ
Jul 6 '06 #72
Mark McIntyre wrote:
On Thu, 06 Jul 2006 11:07:57 +0200, in comp.lang.c , Philipp
<si*******@freesurf.chwrote:
>>Ian Collins wrote:
>>Philipp wrote:
Just a newbie question: If you are writing a C++ programm and need some
function to do some stuff (as the OP), is it ok to use a C function
which you found somewhere on the web in your code?

Yes. The only issues are going the other way.

So what's so wrong from the OP about asking for a piece of code in
(either) C or C++ to do some stuff?

If he'd done that, there'd be no problems though the C solution might
have been inappropriate or inefficient or potentially just plain
incorrect in C++. F'rinstance a C solution wouldn't cast the return
from malloc, and might use sizeof('a'). It might be more eficient to
use a container of some sort.

What he instead asked for was a solution in the mythical language
C/C++.
We just face some possibilities:

a) the OP asked a non-senscal question.

b) some other posters offered a non-sensical interpretation of the original
question because they take offense in the string "C/C++" for whatever
reasons.

In interpretation, as in translation, there is a prima-facie principle: if
an interpretation (or translation) renders a phrase patently wrong or
meaningless or non-sensical, chances are that the interpretation is
mistaken. The goal of interpreting some statement or question should be
understanding not ridicule.
Best

Kai-Uwe Bux
Jul 6 '06 #73
Mark McIntyre wrote:
On Wed, 05 Jul 2006 01:00:02 +0200, in comp.lang.c , Kai-Uwe Bux
<jk********@gmx.netwrote:
>>Mark McIntyre wrote:
>>Actually, it was probably because you made an idiotic remark. The fix
is probably to avoid emitting asinine comments, like these...

I would conjecture that it was because Martin Ambuhl and you ignored the
clause "if you take out C++ extensions".

I guess I ignored it because it was as idiotic as the rest of the
remark.

Fortran is pretty much like French, if you take out the Fortran
extensions.
>>different handling of recursion,

could you elaborate on this one

main.
>>exception handling,

Isn't that a C++ extension?

It can't be an extension to C++ since its part of the C++ standard.
>>different IO routines,

The stream IO, I would consider an extension. What are the huge (not
minor) differences between C and C++ with regard to the printf family?

Whats the effect of << in C?
>>different memory management routines,

new/delete is an extension. What are the big differences in malloc/free
between C and C++?

This is a C FAQ.

BTW I forgot to mention operator overload.
Your response shows that your understanding of the term "C++ extension"
seems to be: a language feature offered by some implementation of C++ in
addition to the C++ language as defined per the C++ standard. Although that
is in some contexts a perfectly legitimate interpretation of the
phrase "C++ extension", you should reconsider this reading for the context
of jacob's post. I have provided an alternative interpretation elsethread
that makes more sense. I think, jacob used the phrase "if you take out C++
extensions" to mean: "if you disregard those language features of C++ that
it has in addition to those inherited from C".
Best

Kai-Uwe Bux
Jul 6 '06 #74
Philipp wrote:
Just a newbie question: If you are writing a C++ programm and need some
function to do some stuff (as the OP), is it ok to use a C function
which you found somewhere on the web in your code?
That depends of the meaning of "use". You can compile it with a C compiler,
write a header with the declaration of the function as extern "C" and link
with your C++ code, if you have both compilers available and binary
compatibles. In that case, asking about the function in a C++ group is
nonsense.

Or you can copy the function in a C++ program and compile it as C++. But for
a newbie it can be difficult to verify that the code has the same meaning
in both languages, or to interpret any errors or warnings that may appear
when compiling it as C++. And as a newbie the time will be better used in
learning more C++ that in exploring the differences between C and C++.

--
Salu2
Jul 6 '06 #75

Kai-Uwe Bux wrote:
Mark McIntyre wrote:
On Thu, 06 Jul 2006 11:07:57 +0200, in comp.lang.c , Philipp
<si*******@freesurf.chwrote:
>Ian Collins wrote:
Philipp wrote:
So what's so wrong from the OP about asking for a piece of code in
(either) C or C++ to do some stuff?
If he'd done that, there'd be no problems though the C solution might
have been inappropriate or inefficient or potentially just plain
incorrect in C++. F'rinstance a C solution wouldn't cast the return
from malloc, and might use sizeof('a'). It might be more eficient to
use a container of some sort.

What he instead asked for was a solution in the mythical language
C/C++.

We just face some possibilities:

a) the OP asked a non-senscal question.
There are two very different variants of that

a1) the OP intentionally asked a question they knew to be non-sensical
a2) the OP asked what is actually a non-sensical question but believed
they were asking a meaningful question

Unless the OP was deliberately trolling, a1 is not the case. However,
given the number of people here (and in the real world) who use the
phrase "C/C++" and later reveal a mistaken belief that the distinction
between C and C++ is irrelevant to their question, or even a failure to
understand that the two are sufficiently different that, for all but
the most trivial of questions, the answer in C and the answer in C++
may bear no resemblance to each other, a2 is a definite possibility.
b) some other posters offered a non-sensical interpretation of the original
question because they take offense in the string "C/C++" for whatever
reasons.
I've seen "C/C++" used to mean at least three different things and
rarely is it clear from the context which is meant:

1) I need one solution that will work in both C and C++.
2) I need either a solution in C or a solution in C++. I understand the
distinction and I expect that the C solution would differ from the C++
solution and that the C solution might not work in C++.
3) I need one solution in the language I'm using and I had no idea that
C and C++ were distinct, either formally or idiomatically.

3 is not uncommon and that lack of understanding produces the sort of
hotch-potch of C and C++ code that gets posted here all the time.
Having to work with code like that is frustrating and is probably the
cause of some people's (mine included) irritation at the use of the
term "C/C++".
In interpretation, as in translation, there is a prima-facie principle: if
an interpretation (or translation) renders a phrase patently wrong or
meaningless or non-sensical, chances are that the interpretation is
mistaken. The goal of interpreting some statement or question should be
understanding not ridicule.
The possibility here is that interpretation that rendered the question
patently wrong could well have been exactly the right interpretation
because of a lack of understanding on the questioner's part.

Notwithstanding the irritation caused, it is undoubtedly more
constructive to educate away the misunderstanding (if misunderstanding
is the reason "C/C++" was used) than to ridicule.

Given that the use of "C/C++" to mean the non-sensical and mythical
combination of the two is not uncommon, I would advise anyone who does
understand the similarities and differences to be explicit to avoid
appearing uneducated. Make it clear whether you mean "an answer in C or
an answer in C++ is sufficient" or "I need an answer that will work in
both C and C++".

Gavin Deane

Jul 6 '06 #76
Al Balmer wrote:
On Thu, 06 Jul 2006 17:43:59 +0200, Philipp <si*******@freesurf.ch>
wrote:

>>Mark McIntyre wrote:
>>>On Thu, 06 Jul 2006 13:14:21 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:

You can use any C function in C++ by qualifying it as
extern "C", and that is it, you can use it as you want!
This is completely wrong.

Sorry if I'm confused.
in FAQ http://www.parashift.com/c++-faq-lit....html#faq-32.5
it says that "you can declare the individual C function in your C++ code
using the extern "C" syntax"

Is this wrong? (!)


"Declare" is not the same as "use." The "extern C" wrapper just
disables name mangling, so that the function is called with it's
proper name. It doesn't magically make non-C code C++ compatible.

Normally, the way this is used is that you have a C function (perhaps
in a library) which has been compiled by a C compiler. You want to
call this function from a C++ program. If you declare it in the normal
way, the compiler will transform ("mangle") the name by adding
information about the parameter types, for example. The name generated
won't match the name of the C function, and the linker won't be able
to find it. If you declare the function using "extern C", the C++
compiler will leave the name as is.
And this means that both languages are binary compatible, hence very
close, as I am arguing since quite a few posts.

This is a FAQ, and the answer is in the C++ FAQ. I am not proposing
something so stupid that I can be treated "an idiot", (by Mr Ambuhl)
or "mentally retarded" (by Mr Gotham) or whatever!!!

Today good manners are considered a thing from the past. Violence
and provocation are the best way to impose your opinions. It is no
longer important to convince other participants in the discussion but
to be crowned as the "alpha male" of the group and build a circle
of religious followers.

People that do not feel this urgent need to make a sect, are "free
game" and can be insulted at will.

Jul 6 '06 #77
On Thu, 06 Jul 2006 21:29:18 +0200, jacob navia
<ja***@jacob.remcomp.frwrote:
>Al Balmer wrote:
>On Thu, 06 Jul 2006 17:43:59 +0200, Philipp <si*******@freesurf.ch>
wrote:

>>>Mark McIntyre wrote:

On Thu, 06 Jul 2006 13:14:21 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:

>You can use any C function in C++ by qualifying it as
>extern "C", and that is it, you can use it as you want!
This is completely wrong.

Sorry if I'm confused.
in FAQ http://www.parashift.com/c++-faq-lit....html#faq-32.5
it says that "you can declare the individual C function in your C++ code
using the extern "C" syntax"

Is this wrong? (!)


"Declare" is not the same as "use." The "extern C" wrapper just
disables name mangling, so that the function is called with it's
proper name. It doesn't magically make non-C code C++ compatible.

Normally, the way this is used is that you have a C function (perhaps
in a library) which has been compiled by a C compiler. You want to
call this function from a C++ program. If you declare it in the normal
way, the compiler will transform ("mangle") the name by adding
information about the parameter types, for example. The name generated
won't match the name of the C function, and the linker won't be able
to find it. If you declare the function using "extern C", the C++
compiler will leave the name as is.

And this means that both languages are binary compatible, hence very
close, as I am arguing since quite a few posts.
Well, sort of, but I don't want to get into this. I think, especially
considering the remainder of your post, that you must have meant to
reply to some other message.
>
This is a FAQ, and the answer is in the C++ FAQ. I am not proposing
something so stupid that I can be treated "an idiot", (by Mr Ambuhl)
or "mentally retarded" (by Mr Gotham) or whatever!!!

Today good manners are considered a thing from the past. Violence
and provocation are the best way to impose your opinions. It is no
longer important to convince other participants in the discussion but
to be crowned as the "alpha male" of the group and build a circle
of religious followers.

People that do not feel this urgent need to make a sect, are "free
game" and can be insulted at will.

--
Al Balmer
Sun City, AZ
Jul 6 '06 #78
On 2006-07-06, jacob navia <ja***@jacob.remcomp.frwrote:
Al Balmer wrote:
>Normally, the way this is used is that you have a C function (perhaps
in a library) which has been compiled by a C compiler. You want to
call this function from a C++ program. If you declare it in the normal
way, the compiler will transform ("mangle") the name by adding
information about the parameter types, for example. The name generated
won't match the name of the C function, and the linker won't be able
to find it. If you declare the function using "extern C", the C++
compiler will leave the name as is.

And this means that both languages are binary compatible, hence very
close, as I am arguing since quite a few posts.
I have a great free book called "PC Assembly Language" which explains
how to set up your assembly functions so that they'll link with C. By
your definition, C and x86 Assembler are binary compatible.

Does that make them very close languages?

--
Andrew Poelstra <http://www.wpsoftware.net/projects/>
To email me, use "apoelstra" at the above domain.
"You people hate mathematics." -- James Harris
Jul 6 '06 #79
jacob navia said:

<snip>
>
Today good manners are considered a thing from the past.
Not entirely. There are still /some/ people who observe topicality, who
refrain from making incorrect "corrections" or at least have the grace to
apologise when they do so, who don't habitually plug their principal
product, and so on and so on.
Violence and provocation are the best way to impose your opinions.
They cut little ice on Usenet, and anyway, to "impose" your opinions is
never a good idea. Persuasion is much more effective, and you won't
persuade people without being able to present a reasoned case.
It is no
longer important to convince other participants in the discussion
It never was. Convincing people is utterly unimportant. The goal is truth,
not conviction, and in clc (and presumably in clc++) we arrive at truth by
having reasoned discussion with due reference to the Standard.

<nonsense snipped>

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 6 '06 #80
jacob navia <ja***@jacob.remcomp.frwrites:
Al Balmer wrote:
>On Thu, 06 Jul 2006 17:43:59 +0200, Philipp <si*******@freesurf.ch>
wrote:
>>>Mark McIntyre wrote:
On Thu, 06 Jul 2006 13:14:21 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>You can use any C function in C++ by qualifying it as
>extern "C", and that is it, you can use it as you want!

This is completely wrong.

Sorry if I'm confused.
in FAQ http://www.parashift.com/c++-faq-lit....html#faq-32.5
it says that "you can declare the individual C function in your C++
code using the extern "C" syntax"

Is this wrong? (!)
"Declare" is not the same as "use." The "extern C" wrapper just
disables name mangling, so that the function is called with it's
proper name. It doesn't magically make non-C code C++ compatible.
Normally, the way this is used is that you have a C function (perhaps
in a library) which has been compiled by a C compiler. You want to
call this function from a C++ program. If you declare it in the normal
way, the compiler will transform ("mangle") the name by adding
information about the parameter types, for example. The name generated
won't match the name of the C function, and the linker won't be able
to find it. If you declare the function using "extern C", the C++
compiler will leave the name as is.

And this means that both languages are binary compatible, hence very
close, as I am arguing since quite a few posts.
No, C and C++ are not "binary compatible"; that's not even a
meaningful statement.

A given *implementation* of C might be binary compatible with a given
*implementation* of C++. My understanding (I'm not a C++ expert) is
that C++'s extern "C" feature allows you to invoke a C function from a
C++ program only if the two implementations happen to be binary
compatible. It's very common that such implementations are available
(possibly from the same vendor), but I'm not aware of anything in
either standard that requires it.

[remaining jacobspeak snipped]

--
Keith Thompson (The_Other_Keith) 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.
Jul 6 '06 #81
On Thu, 06 Jul 2006 21:29:18 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>And this means that both languages are binary compatible,
Sort of, yes...
>hence very close,
.... but no, this isn't true.

On my vax I could call Fortran libraries from C, and vice-versa. This
doesn't make the languages very close, merely callable from one
another.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 6 '06 #82
Mark McIntyre <ma**********@spamcop.netwrites:
On Thu, 06 Jul 2006 21:29:18 +0200, in comp.lang.c , jacob navia
<ja***@jacob.remcomp.frwrote:
>>And this means that both languages are binary compatible,

Sort of, yes...
>>hence very close,

... but no, this isn't true.

On my vax I could call Fortran libraries from C, and vice-versa. This
doesn't make the languages very close, merely callable from one
another.
If the *languages* were callable from one another, I could call a
Fortran library on your VAX from my C program on my PC.

The Fortran and C *implementations* on your VAX are binary compatible,
not the languages themselves.

--
Keith Thompson (The_Other_Keith) 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.
Jul 6 '06 #83
On Thu, 06 Jul 2006 20:09:16 GMT, Keith Thompson <ks***@mib.org>
wrote:
>A given *implementation* of C might be binary compatible with a given
*implementation* of C++. My understanding (I'm not a C++ expert) is
that C++'s extern "C" feature allows you to invoke a C function from a
C++ program only if the two implementations happen to be binary
compatible.
Yes. In fact, binaries generated by two perfectly conforming C
compilers may not be compatible, since it's common for library code to
call invisible helper functions which are not standardized. If you
link C code with C++ code, it's best if they're generated by two
different modes of the same compiler. That's the reason that
commercial libraries come in different versions for different
compilers.

--
Al Balmer
Sun City, AZ
Jul 6 '06 #84
On Thu, 06 Jul 2006 21:08:13 GMT, in comp.lang.c , Keith Thompson
<ks***@mib.orgwrote:
>The Fortran and C *implementations* on your VAX are binary compatible,
not the languages themselves.
Indeed, this is what I meant, though I agree I was unfortunately
ambiguous. Languages aren't binary at all.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Jul 6 '06 #85
Frederick Gotham wrote:
jacob navia posted:
>You can use any C function in C++ by qualifying it as extern "C", and
that is it, you can use it as you want!
Not quite "any"; the function declaration must still be correct
C++ code, e.g. this is no good:

extern "C" int new(int delete);

and I think it mustn't have the same name as any overloaded C++
function in the same module (due to name mangling requirements).

Also, the function body must conform to a C ABI that the C++
compiler knows about.
Must every C++ compiler provide a facility for compiling C code?
No, but I don't know of any that don't.
Can the following program be considered universally portable?

/* stuff.c */

#include <stddef.h>
#include <stdlib.h>

char *AllocCharArray( size_t const len )
{
return malloc(len);
}

/* main.cpp */

#include <cstdlib>

extern "C" { char *AllocCharArray( std::size_t const len ); }
Note, the braces are unnecessary.
>
int main()
{
char * const p = AllocCharArray(64);

std::free(p);
}
I guess it is a semantic issue about the word "portable". If you're
happy for it to include "portable to systems with both a C++
compiler and a compatible C compiler" , then yes. Note that
there are other practical issues too; the two compilers must
also be configured to link gainst the same runtime library.

Jul 7 '06 #86
In article <e8**********@murdoch.acc.Virginia.EDU>,
Kai-Uwe Bux <jk********@gmx.netwrote:
....
>In interpretation, as in translation, there is a prima-facie principle: if
an interpretation (or translation) renders a phrase patently wrong or
meaningless or non-sensical, chances are that the interpretation is
mistaken. The goal of interpreting some statement or question should be
understanding not ridicule.
That's not how it works on Usenet. Generally, you assume that the
poster is a complete dumbdumb and go from there. Generally, you are
right to do so. But not always.

And, of course, clc is the worst offender - that's what makes this NG so
much fun. It's like shooting fish in a barrel. Here, Jacob made it
real clear that his posts were *not* to be interpreted in the default
way, that is, as if he had an IQ of 6, but the "regulars" couldn't give
an inch. They have made a life's work of ignoring your quite reasonable
rule (above). So typical.

Useful clc-related links:

http://en.wikipedia.org/wiki/Clique
http://en.wikipedia.org/wiki/Aspergers
http://en.wikipedia.org/wiki/C_programming_language

Jul 7 '06 #87
In article <44*********************@news.orange.fr>,
jacob navia <ja***@jacob.remcomp.frwrote:
....
>Today good manners are considered a thing from the past. Violence
and provocation are the best way to impose your opinions. It is no
longer important to convince other participants in the discussion but
to be crowned as the "alpha male" of the group and build a circle
of religious followers.
So true, so true. Of course, all the alpha male wannabees will deny it.
Mark my words. Read the links below and your anger will be replaced by
amusement and pity. You will be the better for it.
>People that do not feel this urgent need to make a sect, are "free
game" and can be insulted at will.
You got it.

Useful clc-related links:

http://en.wikipedia.org/wiki/Clique
http://en.wikipedia.org/wiki/Aspergers
http://en.wikipedia.org/wiki/C_programming_language

Jul 7 '06 #88
Julián Albo wrote:
for
a newbie it can be difficult to verify that the code has the same meaning
in both languages,
So what you are saying is that the same lines of code may have different
meanings if compiled with a C++ compiler or a C compiler?
Can you show an example?
Thanks
Jul 7 '06 #89

Philipp wrote:
Julián Albo wrote:
for
a newbie it can be difficult to verify that the code has the same meaning
in both languages,

So what you are saying is that the same lines of code may have different
meanings if compiled with a C++ compiler or a C compiler?
Can you show an example?
Thanks
See

Character literals
const linkage
Empty parameter lists
Enumeration constants
Nested structure tags

and others at http://david.tribble.com/text/cdiffs.htm

Gavin Deane

Jul 7 '06 #90
Philipp wrote:
So what you are saying is that the same lines of code may have different
meanings if compiled with a C++ compiler or a C compiler?
Can you show an example?
#include <stdio.h>

int main ()
{
printf ("'a' does %slook like a char\n",
(sizeof 'a' == sizeof (char) ) ? "" : "not ");
return 0;
}

As C:
'a' does not look like a char

As C++:
'a' does look like a char

--
Salu2
Jul 7 '06 #91
Philipp wrote:
Julián Albo wrote:
>for
a newbie it can be difficult to verify that the code has the same meaning
in both languages,


So what you are saying is that the same lines of code may have different
meanings if compiled with a C++ compiler or a C compiler?
Can you show an example?
Thanks
int main()
{
const unsigned size = 42;

float stuff[size];
}

Gives a 'normal' array in C++ and a VLA in C(99).

--
Ian Collins.
Jul 7 '06 #92
Old Wolf <ol*****@inspire.net.nzwrote:
Frederick Gotham wrote:
>Must every C++ compiler provide a facility for compiling C code?

No, but I don't know of any that don't.
The HP aCC C++ compiler will not compile C code that uses the old-style
function parameter declarations, e.g.,

int func(a, b)
int a;
int b;
{
return 0;
}

as opposed to the modern

int func(int a, int b)
{
return 0;
}

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jul 11 '06 #93

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

Similar topics

0
by: CroDude | last post by:
Hi all! I have problems when writting bitmap to a byte array and after reading it back form byte to Bitmap object. What I do is this: First I throw Bitmap to a memory-stream and then I write it...
3
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id if the picture (an integer) and one (column named picture) is a field of type OLE Object which...
5
by: Sumana | last post by:
Hi All, We developed our project on VC++.Net console application to create image of disk and to write the image We are having problem with reading and writing the sector beyond 6GB Disk or...
2
by: Alan | last post by:
Hello, I am making a web page where I need to show somewhere in the page a webcam without component like activex. In my webcam I can read the last picture with the following command:...
15
by: mosipenko | last post by:
I used to have a problem with DBNull, but now my issue is: System.InvalidOperationException: Invalid attempt to read when no data is present Here's my code behind: Private Sub...
1
by: Blasting Cap | last post by:
I would like to try to see if an image uploaded to a SQL database is over a specific size, and if so, to resize it when it is displayed. The following is in the Page_load event. Dim strImageID...
3
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT...
3
by: eholz1 | last post by:
Hello PHP Group, I am having trouble setting permissions correctly so that the magickwand api (php 5.2) can read and write images. I usually read a file from one directory, create a magickwand...
4
by: Pacino | last post by:
Hi, everyone, I am wondering whether it's possible to read part (e.g. 1000*1000) of a huge jpeg file (e.g. 30000*30000) and save it to another jpeg file by pure python. I failed to read the...
70
by: quickcur | last post by:
hi can anyone explain me to read image to memory from a url it is very easy in java but it is hard to find an complete solution in c/c++. Thanks,
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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...

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.