Jump to content

[Resolvido] Variáveis externas


dario1133
 Share

Recommended Posts

Tenho no ficheiro 1.c:

char MAC[6];

MAC[0] = u8EEEPROMread(address[0]);

Para conseguir usar esta variável no ficheiro 2.c fiz:

extern char MAC[6];

Só que depois quando tento usar a variável, não consigo. estou a definir alguma coisa mal?

Edited by thoga31
GeSHi
Link to comment
Share on other sites

// fich1.h

#ifndef FICH1_H
#define FICH1_H

extern char MAC[6];

#endif

// fich1.c

#include "fich1.h"

// ok em usar a variável MAC

// entanto tem de estar instanciada ...
char MAC[6];

// fich2.c

#include "fich1.h"

// ok em usar a variável MAC
Edited by HappyHippyHippo
IRC : sim, é algo que ainda existe >> #p@p
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.