MicroChip C30 problema
Miko, Imre
imre.miko at siemens.com
Wed Sep 26 13:22:47 CEST 2007
Hello,
En avr-en igy csinaltam:
typedef struct {
unsigned b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1, b7:1;
} bitv;
#define __paste(a,b) a##b
#define _paste(a,b) __paste(a,b)
#define bitof(var,num) (((bitv *)&(var))->_paste(b,num))
A fenti egy base.inc-ben van, amit mindehova beincludalok.
Igy lehet hasznalni:
#define FLAG_HOLD bitof(flags,0)
FLAG_HOLD=0;
Udv
Imre
> -----Original Message-----
> From: elektro-bounces at tesla.hu
> [mailto:elektro-bounces at tesla.hu] On Behalf Of Balla Zoltán
> Sent: 2007. szeptember 26. 10:08
> To: elektro at tesla.hu
> Subject: MicroChip C30 problema
>
> Sziasztok!
>
> Jelzobiteket szeretnek letrehozni egy DsPIC projectben, de a
> C18 forditonal mukodo modon itt nem tudom egy az egyben
> felhasznalni a modszert. C18-nal igy csinaltam:
>
> valamelyik modulban letrehoztam egy strukturat:
> struct Bitmezo{
> unsigned Bit0:1;
> unsigned Bit1:1;
> unsigned Bit2:1;
> unsigned Bit3:1;
> unsigned Bit4:1;
> unsigned Bit5:1;
> unsigned Bit6:1;
> unsigned Bit7:1;
> }MFB;
>
> majd a header file-ban :
> extern struct Bitmezo{
> unsigned Bit0:1;
> unsigned Bit1:1;
> unsigned Bit2:1;
> unsigned Bit3:1;
> unsigned Bit4:1;
> unsigned Bit5:1;
> unsigned Bit6:1;
> unsigned Bit7:1;
> }MFB;
>
> #define xxx MFB.Bit0
> #define yyy MFB.Bit1
> .....
>
> definialtam az egyes biteket. Innentol kezdve az osszes
> modulban, melyekben belinkeltem a header file-t, elerhetoek
> voltak az xxx, yyy bitek.
> Ez szepen mukodott is eddig a C18 forditoval, de a C30 nem
> akarja elfogadni.
> Ezt a hibauzenetet adja:
> Main.c:12: error: redefinition of 'struct Bitmezo'
>
> A kerdesem az lenne, hogy miert nem fogadja el ezt a C30,
> amikor a C18 nem problemazik vele ?? Illetve, ha ez igy nem
> korrekt, akkor mikent kell ezt megvalositani, hogy
> szabvanyosabb modon ne fuggjon a forditotol ennyire!
>
> Zoli
>
> -----------------------------------------
> elektro[-flame|-etc]
>
More information about the Elektro
mailing list