View previous topic :: View next topic |
Author |
Message |
John Kiro
Joined: 18 Nov 2006 Posts: 18
|
Posted: Fri Feb 09, 2007 2:36 pm Post subject: Bug with the include pragma? |
|
|
Hello Derek
I'm having a problem with the include pragma:
- I'm using it like this:
Code: |
pragma(include,`C:\projects\MyDLL\mydll`);
|
where the file mydll.d contains this declaration:
Code: |
extern(Windows) void TestFunc(uint a, uint b);
|
But the compiler emits an error that the function TestFunc is not defined.
I added some trace statements in the source.d (bud source code) in the section handling include pragma, to see if it reads the path & the imported file correctly, here is the output using my modified bud:
ItCompiles.d(43): Error: undefined identifier TestFunc
ItCompiles.d(43): Error: function expected before (), not TestFunc of type int
lCurrentToken contains: C:\projects\mydll\mydll
ModuleToFilename(lCurrentToken) returns: C:\projects\mydll\mydll.d
mReferencedImports contains: [C:\dmd\src\phobos\std\stdio.d,C:\dmd\src\phobos\std\string.d,C:\projects\mydll\mydll.d]
From this I see that the module is identified correctly, but what is strange is that this trace output appears after the compiler error
May be this is the bug? I.e. the include pragma is treated after the compilation?
Regards,
John |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Sat Feb 10, 2007 10:16 am Post subject: Re: Bug with the include pragma? |
|
|
John Kiro wrote: | Hello Derek
I'm having a problem with the include pragma:
- I'm using it like this:
Code: |
pragma(include,`C:\projects\MyDLL\mydll`);
|
where the file mydll.d contains this declaration:
Code: |
extern(Windows) void TestFunc(uint a, uint b);
|
But the compiler emits an error that the function TestFunc is not defined.
I added some trace statements in the source.d (bud source code) in the section handling include pragma, to see if it reads the path & the imported file correctly, here is the output using my modified bud:
ItCompiles.d(43): Error: undefined identifier TestFunc
ItCompiles.d(43): Error: function expected before (), not TestFunc of type int
lCurrentToken contains: C:\projects\mydll\mydll
ModuleToFilename(lCurrentToken) returns: C:\projects\mydll\mydll.d
mReferencedImports contains: [C:\dmd\src\phobos\std\stdio.d,C:\dmd\src\phobos\std\string.d,C:\projects\mydll\mydll.d]
From this I see that the module is identified correctly, but what is strange is that this trace output appears after the compiler error
May be this is the bug? I.e. the include pragma is treated after the compilation?
Regards,
John |
The problem is that you are using a DLL and these are never linked in at link time. A DLL must be linked/loaded at runtime. There is a tool that creates a shim library such that you can link it in at compile time and when it gets to run, it automagically loads the DLL and access the entity in it for you. I can't remember the name but I'm sure someone else here will. In the mean time I'll research it a bit more. _________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
John Kiro
Joined: 18 Nov 2006 Posts: 18
|
Posted: Sat Feb 10, 2007 1:59 pm Post subject: |
|
|
Derek,
The problem has nothing to do with the fact that I'm trying to link a DLL:
The error is coming from the compiler, not the linker.
I was trying to use include as an alternative to import, because it gives more flexibility in specifying the path.
Can you provide an example usage of it?
Quote: |
There is a tool that creates a shim library such that you can link it in at compile time and when it gets to run, it automagically loads the DLL and access the entity in it for you. I can't remember the name but I'm sure someone else here will. In the mean time I'll research it a bit more.
|
I guess you're speaking about implib. Yes it introduces the DLL to the linker, but also the exported functions need to be introduced to the compiler, and that's what I am trying to do with include, but which does not work. It works with import on the other hand.
Regards,
John |
|
Back to top |
|
|
Derek Parnell
Joined: 22 Apr 2004 Posts: 408 Location: Melbourne, Australia
|
Posted: Sat Feb 10, 2007 7:55 pm Post subject: |
|
|
John Kiro wrote: | Derek,
The problem has nothing to do with the fact that I'm trying to link a DLL:
The error is coming from the compiler, not the linker.
I was trying to use include as an alternative to import, because it gives more flexibility in specifying the path.
Can you provide an example usage of it?
|
Sorry, I was too quick to answer. The 'include' is designed to tell Bud about modules (i.e. D Source Code files) that are not imported but still contain useful information for Bud to analyze the file dependancies. The file mentioned in the pragma is not passed to the compiler. I should make this more clear in the documentation.
John Kiro wrote: |
I guess you're speaking about implib. Yes it introduces the DLL to the linker, but also the exported functions need to be introduced to the compiler, and that's what I am trying to do with include, but which does not work. It works with import on the other hand. |
Are you saying that "import my.dll;" works!? I didn't think DMD was that cleaver. That's why I thought one needed to use implib to create a "my.lib" from the DLL and then add "my.lib" to the command line.
Here is a sample that I use to create the Bud documentation...
Code: |
/* This is used to generate the user manual for Bud.
--usage:
build um.d -clean
*/
version(build)
{
pragma(nolink);
pragma(include, user_manual.ddoc);
pragma(include, pragmas);
pragma(include, introduction);
pragma(include, User_Manual);
pragma(include, rules);
pragma(include, autobuild);
pragma(include, command_line);
pragma(include, switches);
pragma(include, configuration_file);
pragma(include, response_file);
pragma(include, todo);
pragma(include, dlls);
pragma(include, change_log);
pragma(include, macros);
}
|
_________________ --
Derek
skype name: derek.j.parnell |
|
Back to top |
|
|
John Kiro
Joined: 18 Nov 2006 Posts: 18
|
Posted: Sun Feb 18, 2007 1:30 pm Post subject: |
|
|
Hi Derek
Sorry for my late answer.
Quote: |
The 'include' is designed to tell Bud about modules (i.e. D Source Code files) that are not imported but still contain useful information for Bud to analyze the file dependancies.
|
Please provide simple examples in the documentation, and explain what bud does exactly, and when (in which stage).
Quote: | Are you saying that "import my.dll;" works!? I didn't think DMD was that cleaver. That's why I thought one needed to use implib to create a "my.lib" from the DLL and then add "my.lib" to the command line. |
No of course not. "import my.dll;" would not work. I meant that I was thinking that pragma(include,myfile); would be equivalent to import myfile;, which turned out to be not true.
Regards,
John |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|