Search code examples
c++cvariablesobjectsystem

Calling a native C function after making a variable with that name


I have a pretty large application which holds most of the program data in a large container object called system.

So I access things all the time, e.g. printf("%s\n",system.constants.jobname);, and changing the name of system is undesirable.

I learned later that the function system exists as a native C function for running terminal commands, e.g. system("rm *.txt");

My problem is that I get compilation errors trying to use system as a function because it's already defined as an object.

Is there any way one can call a native C function explicitly ignoring programmatically defined variables? Or give the native system function an alias? (I'm using C++ so using it would be fine)


Solution

  • If you're using C++, system is in the global namespace. Assuming you've put your stuff in a proper namespace (you have, right?) you can refer to it as ::system.