Reputation: 49
First I still embrace the concept of a dll and now I'm trying to make one for myself but i get this when i try to build:
error C2059: syntax error: '__declspec(dllimport)'
error C2238: unexpected token(s) preceding ';'
error C2059: syntax error: '__declspec(dllimport)'
error C2238: unexpected token(s) preceding ';'
Vec2.h:
#pragma once
#ifdef VECTORLIB_EXPORTS
#define VECTORLIB_API __declspec(dllexport)
#else
#define VECTORLIB_API __declspec(dllimport)
#endif
class Vec2
{
public:
Vec2() = default;
VECTORLIB_API Vec2(double x, double y);
Vec2 VECTORLIB_API operator+(Vec2& rhs);
Vec2 VECTORLIB_API operator*(double& rhs);
Vec2& VECTORLIB_API operator+=(Vec2& rhs);
Vec2& VECTORLIB_API operator*=(double& rhs);
public:
//public vars///////
double x, y;
////////////////////
};
stdafx.h:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN// Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include "Vec2.h"
// TODO: reference additional headers your program requires here
Vector2.cpp:
// Vector2.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
Vec2::Vec2(double x, double y) : x(x), y(y) {}
Vec2 Vec2::operator+(Vec2& rhs)
{
return Vec2( x + rhs.x, y + rhs.y );
}
Vec2 Vec2::operator*(double& rhs)
{
return Vec2( x * rhs, y * rhs );
}
Vec2& Vec2::operator+=(Vec2& rhs)
{
return ( *this = *this + rhs );
}
Vec2& Vec2::operator*=(double& rhs)
{
return ( *this = *this * rhs);
}
The dll is a start of a vector2d class for me to use later. I understand that the code is probably not in the way it is supposed to be but i'm just starting to hang on these concepts so any tips are more than welcome.
Upvotes: 0
Views: 117