Sorry if this is a duplicate or if this is the wrong place to ask for this but I cannot find any instructions on what I should do.

This is my problem:

Earlier today I asked this question about using extern const in an header file to make my global variables (that can be changed by the implementation) read only to the files that include my header in C and C++.

At the time I started to write it I thought that it was valid because I had managed to compile a test program with GCC where I had extern const int global_variable in the header file but int global_variable in the implementation file.

I later started to doubt that it was valid because I had never seen or heard of it before so I asked this question on stackoverflow to make sure.

It turned out that the only reason I got it to compile was because I did not include my header file in my implementation file.

What should I do in this situation? I think my question on programmers.stackexchange should be deleted but I am not sure.

1 Answer 1


There is no need to do anything.

The fact that your question was triggered by an error in your code and that the trick doesn't work when correcting that error doesn't mean that your question doesn't have a place here. Thus there is no need to close/delete the question.

By indicating in the question that the trick you described doesn't work (and the answer why) are enough to warn others.
That is also a reason to leave the question on the site. You are probably not the only one to think of this and by leaving it on the site you can help others as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .