question

DanielShepherd-8507 avatar image
0 Votes"
DanielShepherd-8507 asked rupeshshukla-4529 edited

How can i uninclude a header int C++

So, obviously, there is a #include function in c/c++, but I want to UNinclude a header. Does anyone know how?

c++
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can you give a specific example of what you are trying to accomplish?

Generally, headers can be included or omitted by using conditional compilation.

For example,

 #ifdef INCLUDE_IT
 #include "Someheader.h"
 #endif

But unlike #define/#undef for macros the preprocessor has no such support for header files.

0 Votes 0 ·

You cannot automatically undo everything that an #include has done. You can however selectively and explicitly undo much of what it has done, although experts will say to use a different solution to any problem. So as has been said already, please provide specific details of what you need to do. Note that #include is not a function, it is a pre-processor statement.



0 Votes 0 ·

Ok. So I am making it so that in my solution, once you click the mouse in the win32 app project in the solution, it outputs something in another console app project. so I want to change the header, then sort of uninclude it.

0 Votes 0 ·
SimpleSamples avatar image
0 Votes"
SimpleSamples answered

Based on your comment you probably want to use the Process Class. I assume you want to write something to a different program. You will need to set the ProcessStartInfo.RedirectStandardInput Property to true. Look at the sample code in the documentation. Also if you need to also get output from the other program then see How to redirect Standard Input/Output of an application - CodeProject.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

rupeshshukla-4529 avatar image
0 Votes"
rupeshshukla-4529 answered rupeshshukla-4529 edited

As other has already mentioned that you can use preprocessor directory to control your include file . But I am still not sure if I get your question. What are you trying to accomplish here. Because you can have hook in your other application and you can trap mouse click event and based on your click your preprocessor can act the way you want .

But In your question I still didn't get "once you click the mouse in the win32 app project in the solution, it outputs something in another console app project" then where this include def/undef is coming in picture.

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.