Hello,
I use nant rc1 on Windows XP.
I want to use wrapped functions out of a gcc-generated dll,
but detected following problem:
A function defined via task script doesn't return
when calling a function from a dll created by gcc.
Remarks:
- I attached all test files (zip-file was not possible).
- the build-script finishes when the inner function finishes
without any error message.
- if the dll is used in a main program, no problem occurs.
- if the test-dll is created by MS Visual C, no problem occurs,
but due to other reasons I cannot switch to MS VC.
- gcc -v delivers: gcc version 3.3.3 (cygwin special).
Best regards
Helmut Dipper
#if defined(WIN32)
# define DLL_EXPORT __declspec(dllexport)
#else
# define DLL_EXPORT /**/
#endif
#include <stdio.h>
#include <string.h>
DLL_EXPORT char *dll_fct (char *par)
{
static char buf[1024 + 1];
printf("executing dll_fct\n");
buf[0] = 0;
strcat(buf, "input: ");
strcat(buf, par);
return buf;
}
#include <stdio.h>
#include <string.h>
extern char *dll_fct (char *);
main ()
{
printf("before\n");
printf("%s\n", dll_fct("hello"));
printf("after\n");
}
<?xml version="1.0"?>
<project name="test" default="test">
<script language="C#" prefix="test">
<imports>
<import name="System.Runtime.InteropServices"/>
</imports>
<code>
<![CDATA[
[DllImport("test.dll",
EntryPoint="dll_fct",ExactSpelling=true,
CharSet=CharSet.Ansi,
CallingConvention=CallingConvention.StdCall
)]
private static extern string dll_fct(string par);
[Function("call")]
public static string call(string par)
{
string res;
res = dll_fct(par);
return res;
}
]]>
</code>
</script>
<target name="test">
<echo message="begin"/>
<echo message="${test::call('test')}"/>
<echo message="end"/>
</target>
</project>
cl -IE:/progra~1/visual~1/VC98/include -DDEBUG /Z7 -DWIN32 /nologo /W2 -c fct.c
/e/progra~1/visual~1/VC98/bin/link.exe /DLL /OUT:test.dll
/LIBPATH:E:/progra~1/visual~1/VC98/lib /pdb:none /machine:I386 /nologo
/incremental:no /subsystem:console fct.obj kernel32.lib
cl -IE:/progra~1/visual~1/VC98/include -DDEBUG /Z7 -DWIN32 /nologo /W2 -c main.c
/e/progra~1/visual~1/VC98/bin/link.exe /pdb:none /machine:I386 /nologo
/incremental:no /subsystem:console /OUT:main.exe
/LIBPATH:E:/progra~1/visual~1/VC98/lib main.obj fct.obj kernel32.lib
/e/progra~1/visual~1/VC98/bin/link.exe /pdb:none /machine:I386 /nologo
/incremental:no /subsystem:console /OUT:main.exe
/LIBPATH:E:/progra~1/visual~1/VC98/lib main.obj test.lib kernel32.lib
gcc -O2 -c fct.c
gcc -v -o test.dll -shared fct.o
gcc -O2 -c main.c
gcc -v -o main.exe main.o test.dll