🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fr.comp.lang.c
Article #15506

Re: champ de bits...

#15506
From: Emmanuel Delahaye
Date: Fri, 23 Sep 2005 18:20
64 lines
2135 bytes
Bouloun wrote on 23/09/05 :
> Bonjour
> J'ai un projet qui s'organise co �a:
>
> Main.C
> Appl.c
> Appl.h
>
>     Dans Main .C j'utilise un champ de bit du genre : (d�laration faite juste 
> apr�s les variables globales)
> struct
>    {
>     unsigned t1:1
>     unsigned t2:1
>     }cfg;
>
> Le probl�me c'est que le fichier Appl.c doit lui aussi pouvoir avaoir acc�s � 
> ce champ de bit.
>
> Comment faire pour pouvoir aussi utiliser ce champ de bit dans mon fichier 
> Appl.C ?
>
> merci,

Comme d'habitude : Il faut s�parer la d�finition de la structure de la 
d�finition de la variable.

/* cfg.h */
struct cfg
{
   unsigned t1:1
   unsigned t2:1
};

extern struct cfg cfg;

/* cfg.c */
#include "cfg.h"
struct cfg cfg;

on peut aussi faire comme �a :

/* cfg.h */

extern struct cfg
{
   unsigned t1:1
   unsigned t2:1
}
cfg;

/* cfg.c */
#include "cfg.h"
struct cfg cfg;

mais �a encourage l'usage des globales... beark.

-- 
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
The C-library: http://www.dinkumware.com/refxc.html

 "It's specified. But anyone who writes code like that should be
transmogrified into earthworms and fed to ducks." -- Chris Dollin CLC
Technical Details
Message-ID: <mn.bcc47d5978be9d94.15512@YOURBRAnoos.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-3.proxad.net!news18-e.free.fr!not-for-mail
References: <433442ce$0$12992$7a628cd7@news.club-internet.fr>

Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,f57b8b7d4d821213
X-Google-Attributes: gidf9822,public
X-Google-Language: FRENCH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-3.proxad.net!news18-e.free.fr!not-for-mail
Subject: Re: champ de bits...
From: "Emmanuel Delahaye" <emdel@YOURBRAnoos.fr>
References: <433442ce$0$12992$7a628cd7@news.club-internet.fr>
Newsgroups: fr.comp.lang.c
Message-ID: <mn.bcc47d5978be9d94.15512@YOURBRAnoos.fr>
X-Newsreader: MesNews/1.04.00.00-fr
Date: Fri, 23 Sep 2005 20:20:40 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 66
Organization: Guest of ProXad - France
NNTP-Posting-Date: 23 Sep 2005 20:20:43 MEST
NNTP-Posting-Host: 81.65.109.78
X-Trace: 1127499643 news18-e.free.fr 4356 81.65.109.78:17631
X-Complaints-To: abuse@proxad.net