This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Reassigning pointer to a structure

I'm having trouble with reassigning a pointer to a structure. Given the 2 files, structure.h and structure.c listed below:

structures.h
------------

struct device_struct {
    unsigned char address;
    struct message_struct* message;
    struct device_struct* next;
};

struct message_struct {
    unsigned char id;
};
extern struct device_struct struct_0_dev;

structures.c
------------

#include "structures.h"

struct device_struct struct_0_dev = {0};
struct device_struct struct_1_dev = {0};
struct message_struct msg0 = {0};

void init_structures(void){
    struct_0_dev.address = 0;
    struct_0_dev.message = &msg0;
    struct_0_dev.next = &struct_1_dev;
}

I'm having trouble creating a new pointer in network.c to a device_struct and copying the pointer from a struct_0_dev to the new pointer. If I initialize temp_device_struct in the same line, it works fine (see below):

Network.c
---------

#include "structures.h"

void network_enumeration(void){

struct device_struct* temp_device_struct = &struct_0_dev;
unsigned char temp = 0;

}

However, if I try to do it in a separate line as seen below, the compiler throws a C141 syntax error near the unsigned char temp = 0; line.

Network.c
---------

#include "structures.h"

void network_enumeration(void){

struct device_struct* temp_device_struct;
temp_device_struct = &struct_0_dev;
unsigned char temp = 0;

}

0