Hide Local Identifier

I have written two functions NewMalloc() and NewFree() which are similar to malloc() and free(). They have a global variable of 50000 byte array and its where the memory is allocated dynamically. Everything is written in C , (not C++)

my problem is that i have givent this array, the name(identifier) "NEWMALLOC_mem" which will not allow me to use this word as an identifier in my programs that use these two functions.(they are written in a file called newmalloc.c which is to be linked with my programs).

in C++ this can be solved by using Namespace... but i want this on C..

please help me...
You can make it a static global variable - this will give it internal linkage

SomeFile.c
1
2
3
4
5
static int  aaa;  //Global variable - internal linkage - visible only within this file
void somefunc(void)
{
    aaa = 3; //refers  to the aaa above
}


SomeOtherfile.c
aaa = 3; //refers to some variable called aaa BUT not the one defined in SomeFile.c
Last edited on
thats Great guestgulkan... thank you very much... i new only little about this static keyword.. thanks for everything and the cool code example...
cheers... :)
Topic archived. No new replies allowed.