Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: syntax question (http://www.velocityreviews.com/forums/t961504-re-syntax-question.html)

James Kuyper 06-07-2013 02:31 PM

Re: syntax question
 
On 06/07/2013 09:37 AM, lipska the kat wrote:
> Hi
>
> I'm trying to get my head around Linux shared libraries


Shared libraries are not part of standard C, you'll get better results
asking about them in a forum devoted to Linux.

> I found some simple example code for a *very* simple share library.
>
> http://wiki.linuxquestions.org/wiki/...d_Files#soname
>
> //main
> #include <iostream>
> #include <dlfcn.h>


Those are not C standard headers. You'll have to tell us what they
contain before we can assess their impact on the rest of your code.

> extern "C" void help();


"C" is a syntax error in this context.

> int main()
> {
> help();
> return 0;
> }
>
> //library
> extern "C" void help()
> {
> std::cout << "hello world" << '\n';


"::" is a syntax error. No identifiers named 'std' or cout are defined
in your code. In this context, "hello world" is automatically converted
into a pointer to the first element of the an unnamed array containing
that string. Having either operand of a << operator be a pointer is a
constraint violation. Assuming that your header files provide
declarations for 'std' and 'cout', the simplest fix that makes your
program syntactically valid C code would be to replace :: with =,

It's almost as if you thought that it was appropriate to post questions
about C++ code to a C newsgroup.

> }
>
> I compile this with
>
> make -k
> gcc help.cpp -o libhelp.so -ldl -shared -fPIC
> g++ main.cpp -lhelp


That compiles the code as C++. You'll get better answers to questions
about C++ in a forum devoted to C++.
--
James Kuyper

Eric Sosman 06-07-2013 02:36 PM

Re: syntax question
 
On 6/7/2013 10:31 AM, James Kuyper wrote:
> On 06/07/2013 09:37 AM, lipska the kat wrote:
>>[...]

> That compiles the code as C++. You'll get better answers to questions
> about C++ in a forum devoted to C++.


He trolls the Java groups, too.

--
Eric Sosman
esosman@comcast-dot-net.invalid

osmium 06-07-2013 02:47 PM

Re: syntax question
 
Eric Sosman wrote:

> On 6/7/2013 10:31 AM, James Kuyper wrote:
>> On 06/07/2013 09:37 AM, lipska the kat wrote:
>>> [...]

>> That compiles the code as C++. You'll get better answers to questions
>> about C++ in a forum devoted to C++.

>
> He trolls the Java groups, too.


Everybody that has never posted to the wrong group by a simple, honest
mistake raise your hand.

Why must the default reaction be"
He is a troll
This is homework:




Eric Sosman 06-07-2013 02:53 PM

Re: syntax question
 
On 6/7/2013 10:47 AM, osmium wrote:
> Eric Sosman wrote:
>
>> On 6/7/2013 10:31 AM, James Kuyper wrote:
>>> On 06/07/2013 09:37 AM, lipska the kat wrote:
>>>> [...]
>>> That compiles the code as C++. You'll get better answers to questions
>>> about C++ in a forum devoted to C++.

>>
>> He trolls the Java groups, too.

>
> Everybody that has never posted to the wrong group by a simple, honest
> mistake raise your hand.
>
> Why must the default reaction be"
> He is a troll
> This is homework:


My opinion is based on experience, not on a first-time
off-the-cuff impression. If you'd like to examine the body
of evidence supporting my assessment, you're welcome to peruse
his traffic in comp.lang.java.programmer.

After that, of course, you're free to draw conclusions
that differ from mine. But I might ask: Why must the default
reaction to criticism be to assume it's a default reaction?

--
Eric Sosman
esosman@comcast-dot-net.invalid

James Kuyper 06-07-2013 04:37 PM

Re: syntax question
 
On 06/07/2013 10:47 AM, osmium wrote:
> Eric Sosman wrote:
>
>> On 6/7/2013 10:31 AM, James Kuyper wrote:
>>> On 06/07/2013 09:37 AM, lipska the kat wrote:
>>>> [...]
>>> That compiles the code as C++. You'll get better answers to questions
>>> about C++ in a forum devoted to C++.

>>
>> He trolls the Java groups, too.

>
> Everybody that has never posted to the wrong group by a simple, honest
> mistake raise your hand.


I've posted to a newsgroup unintentionally (twice, recently, this
newsgroup), but I don't remember intentionally posting to a newsgroup
that turned out to be the wrong one. However, my memory's less than
perfectly reliable.

> Why must the default reaction be"
> He is a troll
> This is homework:


Eric implies that he's a repeat offender in the java groups.
I've had few previous interactions with him here, but I got the
impression that he was a newbie - somewhat clueless, as newbies often
are, but not a troll. He might be behaving differently in the Java groups.

"This is homework" seems to be a very reliable guess when someone posts
something worded like a homework problem, and is problematic only when
they've made no attempt to solve it themselves before asking for help
(which is very often the case). I've seen assertions that something
looked like homework proven wrong, but not very often. Implausible
denials that something is homework are far more common.


All times are GMT. The time now is 04:38 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.