Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to set up and use a DLL and read few tutorials on how to do it.
I'd like to know however, why the intellisense is giving me the -cannot open source file "Header.h"- error.
The strange thing is that if I were to include the stdafx.h BEFORE the said Header.h the error subsides, here's the header's code :

C++
#ifndef INDLL_H
#define INDLL_H

#ifdef EXPORTING_DLL
extern __declspec(dllexport) int Triplica(int);
#else
extern __declspec(dllimport) int Triplica(int);
#endif

#endif


.cpp file is empty, except for the include statement where I see the intellisense error.
Again, the warning goes away if I'm going to include stdafx.h before said header

What's the magic behind this ?
I do understand the reason for precompiled headers, but i still can't wrap in my head why it has to be on top of my .cpp file, I never had to do this with other win32 projects
Posted
Comments
Sergey Alexandrovich Kryukov 29-Apr-15 19:03pm    
There is no magic. Just two things: usual rules for definitions, repeated or not and precompiled headers. stdafx.h is included in the file used for precompiled headers. Just read on them. What's unclear?
You did not show the comprehensive code sample, so I don't know where did you screw up things.
—SA

1 solution

Just read on the topic:
http://en.wikipedia.org/wiki/Precompiled_header[^],
https://msdn.microsoft.com/en-us/library/3dxawkbx.aspx[^].

Your problem is one of the consequences of having precompiled headers, but, from your code sample, I cannot see where did you screw up. Just look at your error message thoroughly and apply your logic. If you cannot resolve it, please provide comprehensive code sample with all what matters, but please make it minimal. Such problems are resolved extremely easily.

—SA
 
Share this answer
 
v2
Comments
Member 11287295 2-May-15 17:59pm    
I don't think I really screw up anything, I just created a plain new empty project and selected DLL from the options, the .cpp file has really nothing inside except a single include statement where I try to include the only header created. It gives an intellisense error, which disappears after including stdafx.h. As I said, and i'm just trying to understand what's the reason behind this, since It never happened with other kind of projects
Sergey Alexandrovich Kryukov 2-May-15 20:05pm    
The compilation error is causes by something which could be called "screw up". If you still need more help, you could try to reduce your code to some minimal sample still showing the same error. Than you could show 100% of such code here using "Improve question".
—SA
Member 11287295 5-May-15 18:55pm    
Indeed I really screwd up something. I was including the header with brackets. Thanks anyway
Sergey Alexandrovich Kryukov 5-May-15 19:04pm    
You are welcome.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900