|
i wish someone would tell me the name of this perfect IDE VS is failing to be as awesome as.
|
|
|
|
|
I'll say "vi" and "emacs" now, to prevent rants from people who really mean it.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
I think we all bitch about VS until we try something else and find it's either no better - or worse...
I remember bitching about the initially drab UI revamp from 2010 to 2012. By the time I was using 2013 I never wanted to go back to 2010.
Kevin
|
|
|
|
|
|
inline void function01()
{
}
#include subModule.h
#include mainModule.h
void main (void) {
function01 (); }
Opening subModule.h:
Red line under function01, mouse hover --> Error: "void function01() declaration incompatible with <error-type> (declared at line XXX of "Path\Project\myApp.cpp")"
clean and rebuild
Error: myApp.cpp Line XXX "This declaration has no storage class or type specifier"
Delete the "inline"
Error: LNK2005 due to duplicated object in the mainModule.obj and myApp.obj"
Undo ("inline" back), rebuild...
everything OK.
Good is, what good ends, but...
EDIT: given better names, hopefully makes more sense now.
EDIT2: Deleted the "VS2017" of the subject due to Richard's comment below.
By the way... the project is a Visual C++ Win32 Console with ATL/MFC support (used the new project template) where I am playing around with the external Library / API.
EDIT3: added the "main"
EDIT4: Nevermind... it is working. I just wanted to rant about it.
EDIT5: I'll try to simulate it again. If I manage, I'll post the calls again making sure that I give enough code
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
modified 6-Feb-19 16:37pm.
|
|
|
|
|
That sucks, you probably already know that you can add your .h files in the projects AdditionalIncludeDirectories.
|
|
|
|
|
Been away from VS a lot (last professional project was VC++ 6 in 2007). That means... no, I am not sure to know exactly what you mean.
I have added them in the project solution explorer with "right click >> add >> existent files" as I have seen in many examples and the VS advice tell. The .h got placed in "headers" and the .cpp in "Source Files" folders
It is working relative fine, a re-build mostly solves the situation. Just weird things (like the one described above) from time to time when using something for the first time (although the files are included since the beginning).
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
"... VS doesn't bore you with a predictable behaviour..."
It's a feature!!!
|
|
|
|
|
This is nothing to do with Visual Studio, it is purely down to the way the compiler reads the sources, possibly because you are effectively including foo.h twice in coo.cpp. Try adding the following line to all your header files:
#pragma once
|
|
|
|
|
#pragma once is the first line in every header but in one where it gets replaced by
#ifndef XXX
#define XXX
....
#endif If the header was being included several times the linking errors would be constantly coming (or at least I would expect it), and not that sporadic or depending if the word "inline" is there or not in a single function (there are a lot of things "not inlined" in that header that should trigger it).
Richard MacCutchan wrote: This is nothing to do with Visual Studio, it is purely down to the way the compiler reads the sources, Are you telling me the compiler is not part of VS?
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I suspect there may be some part(s) of your code that we are not seeing. Maybe you should open a proper question with complete details.
Nelek wrote: Are you telling me the compiler is not part of VS? Of course it isn't. I do lots of compiling and linking outside of Visual Studio, calling the compiler directly.
|
|
|
|
|
I have edited the original message, changing a bit the names, I hope it now makes more sense .
EDIT:
Richard MacCutchan wrote: I suspect there may be some part(s) of your code that we are not seeing Over 8k Lines, but I think I have really extracted the relevant parts.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Don't blame MS. It is C/C++.
foo();
Is indeed incompatible with void foo()
The first is implicitly int foo() according to the C language standard!
I'm not sure why a cleanup helped though...
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
megaadam wrote: foo();
Is indeed incompatible with void foo()
The first is implicitly int foo() according to the C language standard!
Note: I believe you, but don't really understand it
I am just calling one function in a place that is declared in another place. That makes a change of type?
I am editing the original question to give another kind of names, not that I just messed it up.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
modified 6-Feb-19 8:49am.
|
|
|
|
|
I have edited the OP...
Which means... your quote would now be...
megaadam wrote: function01();
Is indeed incompatible with void function01()
The first is implicitly int function01() according to the C language standard!
is it still what you say, with the new names in original post?
If yes... I still don't understand it
BTW the project is a Visual C++ Win32 Console with ATL/MFC Support
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
modified 6-Feb-19 8:56am.
|
|
|
|
|
I suggest you try changing the forward declaration:
from: function01(); to: => void function01();
In C++ void func() is different from void func(int i) they are two different function types/signatures that can coexist due to overloading. The return type is also part of of the function type/signature.
What I do not understand how your code could compile at all. I would expect the build to always fail. But maybe there was an object file left over from a previous build with another function signature but same name?
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
I always use warning level 4 and warnings==error with my code and a function without a return type would trigger a warning which would cause the compilation to fail.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
the function01() in myApp.cpp is not a declaration... is the call to that function of the subModule
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
edited again to add main
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Quote: // a bit of stuff for the test
function01 ();//line XXX
// not much more
You omitted possibly important stuff.
if it is something like
void foo()
{
function01 ();}
then it is a function call, you are right and the compiler is wrong.
On the other hand, if
function01 (); stays freely outside a function definition then it is interpreted (actually compiled ) as function declaration, therefore megaadam remarks apply and you are wrong.
|
|
|
|
|
Hi Carlo
yes, I forgot to put the "main ()"
just added it in "Edit3".
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I just re-created the code (without any extra)...
inline.h
#pragma once
inline void function01()
{
}
main.h
#pragma once
#include "inline.h"
main.cpp
#include "main.h"
int main()
{
}
function01();
Got two very clear errors:
E0311 cannot overload functions distinguished by return type alone -> inline.h 3
E0260 explicit type is missing ('int' assumed) -> main.cpp 7
The problem is that C++ is not JavaScript... That function01(); is not a function call but a definition (a re-definition)...
Moving it inside main() (or any other method) will fix any problem...
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge". Stephen Hawking, 1942- 2018
|
|
|
|
|
Kornfeld Eliyahu Peter wrote: #include "main.h"
int main()
{
function01(); // line XXX
}
function01();
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
|
But darling, your car was blocking the garage.
"If we don't change direction, we'll end up where we're going"
|
|
|
|