facing a issue in c code while using global variable

CodeLite's announcements
devilgeek
CodeLite Curious
Posts: 1
Joined: Sun Sep 11, 2016 3:55 pm
Genuine User: Yes
IDE Question: C++
Contact:

facing a issue in c code while using global variable

Post by devilgeek »

i am facing a problem while using globale variable in c language
here is code this is not orignale code but logic is same.
int number;/*Global Variable*/
int main()
{
number=10;
}
fun1()
{
number=20;
}
fun2()
{
number=30;
}

here is output
C:\Windows\system32\cmd.exe /C C:/TDM-GCC-64/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ global_varibale - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale'
mingw32-make.exe[1]: Leaving directory 'C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale'
mingw32-make.exe[1]: Entering directory 'C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale'
C:/TDM-GCC-64/bin/gcc.exe -c "C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale/main.c" -g -O0 -Wall -o ./Debug/main.c.o -I. -I.
C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale/main.c:6:1: warning: return type defaults to 'int' [-Wimplicit-int]
fun1()
^
C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale/main.c:10:1: warning: return type defaults to 'int' [-Wimplicit-int]
fun2()
^
C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale/main.c: In function 'fun1':
C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale/main.c:9:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale/main.c: In function 'fun2':
C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale/main.c:13:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
C:/TDM-GCC-64/bin/g++.exe -o ./Debug/global_varibale @"global_varibale.txt" -L.
mingw32-make.exe[1]: Leaving directory 'C:/Users/devilgeek/Dropbox/My Workspace/Myworkspace/global_varibale'
====0 errors, 4 warnings====




whereas i took this example from ANSI C and in my linux terminal this programme is working correctly.
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: facing a issue in c code while using global variable

Post by eranif »

This is not related to CodeLite (its a "C" question) and definitly not to the "Announcements" sections of this forum
Please post such questions on a "C" board forum
Make sure you have read the HOW TO POST thread
Locked