Welcome to Dream.In.Code
Become a C++ Expert!

Join 136,912 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,732 people online right now. Registration is fast and FREE... Join Now!




Pointer To Array

 
Reply to this topicStart new topic

Pointer To Array

boschow
16 Mar, 2008 - 11:46 PM
Post #1

New D.I.C Head
*

Joined: 7 May, 2007
Posts: 41


My Contributions
Hi all,

I am programing in C and i just came across a problem with the pointer to array. I am tring to do a system that has structures like Digital Inputs, Digital Outputs, Analog Inputs exc... All structures have the same charateristics ...

CODE

typedef union
{
    structu
    {
         unsigned bs:1;
         unsigned bc:1;
         unsigned ba:1;
         unsigned ac:1;
    }bit;
    shor int all;
}DI_Bits;

typedef sruct
{
   DI_Bits   bits;
   UINT16 alm_timer;
   UINT16 delay_time;
   UINT16 sim_delay;
}DigitalInputs;


Since this are separate structures I put bits in an array that holds just bits and "register" in an array that holds just registers.

CODE

// header file
static short int *bits[20];
static short int *reg[20];


Then i made an object to DigitalInputs structure and ...
CODE

//source file
DigitalInputs DI;
//for bits
static short int *bits = {
    &DI.bits.all, // this way I included all other structures that holds the bits
};
// for registers
static short int *bits = {
   &DI.alm_timer,
   &DI.delay_time,
   &DI.sim_delay
};


When I try to compile this with Dev-Cpp, it says that an redelaration occured, while on the Freescale CW just compile this without any problem.
So i am wantering what I did wrong. Since I want to test this with Dev-Cpp before uploading the software on the microchip I am cindly aking you guys for some help.

Thanks and
Best Regards,
BoSCHoW.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 10:03PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month