I created a static library (.lib) with some basical functions. Creating another project (a simple console project) I added this library and its single header file with declarations. However my declarations got a warning for each. Without this header file I cannot call the static library's functions...
Maybe I missed something - or I do something wrong. Any help?
Any well established IDE should have similar tutorials, but the steps will be similar, the IDE must tell the Compiler where to find that new lib file since it might not be in the regular build directory.
I am wrong. This is not literally a warning. This is the little wavy green line on a declaration which has no definition. Sorry for the bad explanation. I am using VS 2022. I have #pragma once. The program works fine as expected. Some say that Intellisense can be quirky ++
No it works fine as expected. The link with the library is done, but I have some green lines under functions' declarations. It's not a problem, but I don't understand why. No warning no error ++
I don't have Visual Studio (I'm a Linux geek). But I know having green squiggles would drive me insane. Looks like there's a way to turn them down:
Here is a quick solution for me. Go to Tools->Options->Environments->Font and Colors->Warning. Then change the color to match your background color. The squiggles are gone but when you mouse over the syntax, it'll still display the warning as tooltip. I like this way better as most of the warnings are useless to me.
Part 2:
On another site they say that green is good and it means that you can add them to intelisense's library, but I didn't find a way to do that. Does an option like that pop up if you right-click it?
turning off intellisense warnings cuts down on a lot of bugged up reporting and nonsense. The normal C++ warnings are much easier to manage and more useful.
No it works fine as expected. The link with the library is done, but I have some green lines under functions' declarations. It's not a problem, but I don't understand why. No warning no error ++
All three mainstream compilers have functionality to suppress diagnostics that originate in third-party code. For cl.exe you probably want to use /external: https://learn.microsoft.com/en-us/cpp/build/reference/external-external-headers-diagnostics?view=msvc-170
Admittedly I don't know for sure whether /external works with intellisense in particular. I don't use VS (though I do use cl.exe) because it's painfully slow and crashes frequently.
intelisense is great: it fills in members and gives mouse over hints and such.
intelisense warnings are junk: they add a bunch of bugged up complaints about non-issues. My current project for example has complaints about functions that use a few KB of stack space, valid enums that are not the gimpy enum class, and other complete nonsense. To date not a single one of them has been useful. A small # of them are probably correct for ultra pedantic code, but remember, this is microsoft complaining that you didn't use an enum class while they have redefined bool and every integer type 3 times over, hidden pointers behind typedefs, offer get functions that are type void and return in the parameter (making you need an extra statement frequently, instead of foo(func()) you have to say type tmp; func(tmp); foo(tmp); ), and has hundreds of other rubbishisms.