tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] TCC and external variables - am I not seeing somethin


From: Aleksandar Kuktin
Subject: Re: [Tinycc-devel] TCC and external variables - am I not seeing something?
Date: Mon, 11 Mar 2013 14:54:12 +0100

Quoting Daniel but replying to both.

>On Sun, 10 Mar 2013 01:12:33 +0100
>Daniel Glöckner <address@hidden> wrote:
>
> [snip]
> 
> > Header files have this:
> > 
> > /*extern*/ nbworks_do_align_t nbworks_do_align;
> 
> It is bad practice to have variable definitions in a header.
> Add the extern to make it a declaration. Then add the definition
> to a single source file in your project.

Right. That was my problem - TCC only exposed it. I've rearranged the
declarations and definitions as explained and it now links.

> > Source files have this:
> > 
> > struct thread_cache *
> >   daemon_internal_initializer(struct thread_cache *tcache) {
> >     extern nbworks_do_align_t nbworks_do_align;
> 
> Why declare the variable inside the function if you have a header
> with a definition/declaration?

Following the example in K&R 2nd ed., Chapter 1.10. However, I didn't
completely understand the chapter (that much is obvious now that I
reread it) and therefore got tangled in the web of my own making.

Thank you people! It now works. If all goes as planed, the
program/library I am working on will be somewhere under
https://gitorious.org/~akuktin/ in a few weeks. Otherwise, one can
google "nbworks".

-- 
You don't need an AI for a robot uprising.
Humans will do just fine.
                     --Skynet



reply via email to

[Prev in Thread] Current Thread [Next in Thread]