error C4430: missing type specifier - int assumed

This is a simple dll project "square" from which I want to export the square function and use it in excel

Funct.cpp
1
2
3
4
double _stdcall square(double & x)
{
 return x * x;
}


deffile.def
1
2
3
LIBRARY ;square
	; EXPORTS
	; square 


After I click on Build solution I get the following :
1
2
3
4
5
6
  deffile1.def
c:\visual studio 2010\projects\square\square\deffile1.def(1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\visual studio 2010\projects\square\square\deffile1.def(2): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\visual studio 2010\projects\square\square\deffile1.def(3): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\visual studio 2010\projects\square\square\deffile1.def(4): fatal error C1004: unexpected end-of-file found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


what am i doing wrong ?

Regards
Last edited on
It doesn't look like you're treating it as a def file, it looks like you're passing that .def file to the compiler. But I can't be sure without seeing how your project is built.
Thanks kbw

i am just following the steps showed in this video : http://www.youtube.com/watch?v=x3WWA8eEX9Q

I am new to c++ and never used the VC++ developement tool so i am not sure I understand how i am passing the .def file to the compiler

EDIT:

I am using VC++ 2010 express edition on Win XP
Last edited on
Should I exclude the .def file from the build ?

I have right clicked on the def file->properties->set item type to not participate in the build then I built the project again and i no longer get the above mentioned error

The problem i am getting now is when i test the square function in VBA I get the error "Can't find dll entry point ..."

VBA code :

1
2
3
4
5
6
7
Declare Function square Lib _
"C:\Visual Studio 2010\Projects\square\Debug\square.dll" (ByRef x As Double) As Double


Sub test()
    MsgBox square(2)
End Sub


Also, when I open the dll with the Dependency walker I don't see the square function- In fact I see no function exports at all

Can anybody please tell me what i am doing wrong ? Thanks
Last edited on
Bump .

Can someone help me with this - I am still stuck.

Thanks.
You don't need a .def file, but if you don't you need to export the functions/classes directly.

I've removed the reference.

For example, your function can be declared as:
1
2
3
4
extern "C" __declspec(dllexport) double _stdcall square(double x)
{
    return x * x;
}


You should move this to the Windows section.
Last edited on
Topic archived. No new replies allowed.