#Visual Studio 2022 falsely believes #includes are not used.

1 messages · Page 1 of 1 (latest)

pallid rivetBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

cursive meteor
#

I'm having the same problem again in the same project due to use of a ```cpp
std::ofstream

I believe this system to be from ```cpp
#include <fstream>
```however it claims it is unused and asks for its removal. Removing the include immediately marks all mentions of it with errors, again proving Visual Studio *should* understand the file is necessary.
winter sonnet
#

hm consider unused includes INSIDE the main one?

#

like are your libraries malformed?

tight kestrel
#

Show us OtherFile.h, who knows what you did there exactly.
Also did you create an empty project or C++ console project?

cursive meteor
#

It's an empty project to start, and the best part is that it is completely unrelated to what I put in the other file, I've stripped it down to just

OtherFile.h

#pragma once
namespace OtherFile
{
  void main();
};

OtherFile.cpp

#include "OtherFile.h"
namespace OtherFile
{
  void main()
  {
    
  }
}

and it still throws the same info.

#

It seems to be down to the fact the function is called main, changing the name unfortunately removes the info. :/
However the error still occurs with the fstream inclusion which does not have such an easy fix.

#

One would think that VS would be smart enough to tell the difference between

main();
```and```cpp
OtherFile::main();
winter sonnet
#

dont write the pragma once or something?

tight kestrel
winter sonnet
#

ah ok

#

idk about that

tight kestrel
#

You should also start with Console project or Classical Window App project

winter sonnet
#

yeah lol

tight kestrel
#

Empty Project is something that you have to set up by yourself

#

doable, but why exactly would you?

cursive meteor
tight kestrel
#

Well if you want then go ahead, I don't think you will gain much by it though.

cursive meteor
#

The point was kinda to lose much by it.

pallid rivetBOT
#

This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.

pallid rivetBOT
#

<@undefined>

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

cursive meteor
#

!solved