0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

clコマンドDLL クラスをDLL化

Posted at
> cl func.cpp /LD
func.h
#include <stdio.h>

#define EXPORT

#ifdef EXPORT
#define DLL __declspec(dllexport)
#else
#define DLL __declspec(dllimport)
#endif

class DLL KONEKO
{
	public:
		int age;
		char name[32];
		KONEKO();
		~KONEKO();
		int func(int a);
};
func.cpp
#include "func.h"

KONEKO::KONEKO()
{
}

KONEKO::~KONEKO()
{
}

int KONEKO::func(int a)
{
	return a + 100;
}

> cl main.cpp func.lib
main.cpp
#include <stdio.h>
#include "func.h"

int main(void)
{
	KONEKO *kone = new KONEKO();

	int a = kone->func(10);

	printf("%d\n", a);

	return 0;
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?