Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #423

Re: object file memory

From Bill M <wpmccormick@just_about_everywhere.com>
Newsgroups comp.os.linux.development.apps
Subject Re: object file memory
Date 2012-02-07 16:08 -0600
Organization A noiseless patient Spider
Message-ID <jgs7dk$ng5$1@dont-email.me> (permalink)
References <jgpkvf$c83$1@dont-email.me> <20120207000059.76@kylheku.com> <jgrc5t$5f0$1@dont-email.me> <jgrmj8$6pc$1@dont-email.me> <alpine.DEB.2.00.1202072202080.25401@login01.caesar.elte.hu>

Show all headers | View raw


Ersek, Laszlo wrote, On 2/7/2012 3:09 PM:
> On Tue, 7 Feb 2012, Bill M wrote:
>
>> I have a global declared as follows:
>>
>> __thread OCX_COMM_STATE comm_state = OCX_COMM_START;
>
> That's not only a declaration, it's also an external definition.
> Therefore I think this line is from "foo.c", not "foo.h".
>
>
>> OCX_COMM_STATE is a typedef'd enum.
>>
>> So then, in a function called from the main program
>>
>> comm_state = OCX_COMM_SEND;
>>
>> But it seems not to change.
>
> Is that function in main.c?
>
>
>> Any thoughts? Did I miss something?
>
> You may have forgotten to update the declaration of the variable in
> "foo.h" (or main.c):
>
> extern __thread OCX_COMM_STATE comm_state;
>
> Without this declaration, the code in main.o has no idea about
> comm_state being in TLS.

Thanks. I actually do have the extern declaration in the program that is 
linking in foo, but failed to declare that fact in my post.

Anyway, I see what my problem is: My main program is actually starting 2 
threads: the 1st is a client loop (a TCP client), and the 2nd is my 
failed attempt to interface to it. So, in the client loop thread I have 
one comm_state, and in the interface thread there is another; and of 
course they have no idea about one another. I need to restructure this 
program and design a better interface.

I'm trying to encapsulate all of the TCP client interaction in one 
object file, and then link that into various other applications that 
want to use this client to talk to the server. I'm not a very good 
programmer, so it's going to take me a couple of tries to make something 
that is robust.

Thanks!!

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-06 16:41 -0600
  Re: object file memory Kaz Kylheku <kaz@kylheku.com> - 2012-02-06 23:07 +0000
    Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:23 -0600
      Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:40 -0600
        Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:58 -0600
      Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 11:21 -0600
        Re: object file memory "Ersek, Laszlo" <lacos@caesar.elte.hu> - 2012-02-07 22:09 +0100
          Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 16:08 -0600
            Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-08 20:42 -0600
              Re: object file memory Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-02-09 19:00 +0000
            Re: object file memory Joe Beanfish <joe@nospam.duh> - 2012-02-09 11:15 -0500

csiph-web