Visual studio projects have a folder for header files. So, I put the header file in there thinking I would be able to type #include "SDL.h", but that didn't work. I did some searching for it and found nothing helpful.
Place your caret on the first line of any C# or Visual Basic file. Press Ctrl+. to trigger the Quick Actions and Refactorings menu. Select Add file header. To apply the file header to an entire project or solution, select Project or Solution under the Fix all occurrences in: option.
The main reason is that you can distribute your header files to third parties or customers with your DLL, so they can access to all the types and the compiler can warn you if there is any problem. C# actually removes the concept of header files BUT you can still do it in the same way as C++.
Yes, this will work. Note, however, that if you include a lot of headers in this file and don't need all of them in each of your source files, it will likely increase your compilation time.
Putting the header there only helps organize your files, it doesn't copy the file to the include directories nor makes it automatically visible.
You'll need to add the path to where SDL.h
is located to your project additional include directories.
Just right-click on the project -> Configuration Properties -> C/C++ -> General -> Additional Include Directories.
In fact, you shouldn't have to add SDL.h
to the solution, having the path in the Additional Include Directories is enough.
This folder view that you can see on the left is just project organisation hierarchy - it does not reflect your disk hierarchy and the actual location on the disk of your file can be totally different. And #include takes into account your disk location (and all the search paths set in the project properties)
So, to make short: - Check if your SDL.h file is in a reachable location on disk :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With