Share A Global Variable Across Multiple Files By Using extern | C Programming Example

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

No trash talk....just to the point with crystal clear explanation... thanks mate!!

ethanehunt
Автор

You've made fricking awesome c example playlist enjoying a lot
Thanks :)

ranveervaghela
Автор

Very clear explaination , thank you for doing this.

loadfield
Автор

Thanks! your video helped me a lot with my project :)

DEVVAIBHAV
Автор

Man i like your videos!
Keep it up...

programacionpse
Автор

Thank a lot for your videos!!

if you or someone have tip to my case, i will be grateful
what can i do if i get the error "multiple definition" while i need to get two char[] from the user amd compare them (strcmp function)

danielzuzut
Автор

Thank you for the great explanation, the funtions dont need extern deckaration right?

Lulxec
Автор

Very clear explanation, thank you. I have a question and I hope someone can answer it...
I recently came across a project. Main.c file contains some global variables. and other source files reach those global variables. How this could be possible?
What I mean is here...

Main file:
#include "File1.c"
#include "File2.c"

int pulse=0; //which is global variable in main.c

int main(){

}

File1:
uint_8 function (uint_8){
pulse = some_registers;}


How pulse variable is recognized by File1.c file?

trapsoldiers
Автор

really crisp explanation.

I've got a project working in the manor you outline, extern in C, def in H and access from main. I have several other classes I'd also like to have access to that extern object. But when I try to include it with any of the other files, the compiler doesn't like it. anyone got any ideas?

mtraven
Автор

Thank you so much this was helpful!
Is there a way to change the value of the variable inside the library.c file through the c file in which we included library.c file?
Thank you.

jimmyhopkins
Автор

I have a states.h header file that has no C source file because the states.h only contains an enum of states. I want this enum to be global; how can I make it global and accessible across all the files that include states.h.

//states.h
typedef enum {state1, state2, state3} STATES;
extern STATES state;

I want the state to be global.

mrafayshams