@communistic_sistema
Биохимик, но в программировании немного шарю

Как добавить папку в проект dll Visual Studio?

Существует стандартный проект dll со всем необходимым, которое создается VS еще со старта (dllmain, pch и т.д.).
В dll добавляется другая dll через свойства проекта (Дополнительные каталоги включаемых файлов).
В dll создается add.h и add.cpp. В каждый из них первым делом кладется #include "pch.h", а далее другие ништяки из другой dll. Создаются классы на основе классов импортируемой dll. Все хорошо. DEF файл все видит и проблем нет.
Когда я хочу объединить экспорт (ну допустим у меня теперь есть minus.h), я создаю main.h и main.cpp, а add.h и add.cpp перемещаю в новую папку - add. Это приводит к fatal error C1010 у add.cpp (у заголовка этого нет, я проверял инклюд, вставив ../ перед pch.h).
Я пробую вернуть к начальному положению - без папки add. В main.h пишу инклюд по добавлению add.h. Вызывается ошибка LNK2005. Хотя main.h пустой!!!
Что я делаю не так? Почему я не могу просто добавить папку, и почему при импорте в пустой файл у меня возникает ошибка дублирования определения, если в импортируемой dll нет таких определений?
код add.h
#pragma once
#include "pch.h"
using namespace functionfactory;
namespace functions {
	namespace algebra {
		//constructors
		//(+)
		struct int_add_function : basicfunction {
			using basicfunction::basicfunction;
			void execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream);
		};
		struct float_add_function : basicfunction {
			using basicfunction::basicfunction;
			void execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream);
		};
		struct add_function : muxfunction {
			using muxfunction::muxfunction;
		};
		//(-)
		struct int_sub_function : basicfunction {
			using basicfunction::basicfunction;
			void execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream);
		};
		struct float_sub_function : basicfunction {
			using basicfunction::basicfunction;
			void execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream);
		};
		//(*)
		struct int_mul_function : basicfunction {
			using basicfunction::basicfunction;
			void execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream);
		};
		struct float_mul_function : basicfunction {
			using basicfunction::basicfunction;
			void execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream);
		};
		//(/)
		struct int_div_function : basicfunction {
			using basicfunction::basicfunction;
			void execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream);
		};
		struct float_div_function : basicfunction {
			using basicfunction::basicfunction;
			void execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream);
		};
		//(%)
		//instances
		//(+)
		int_add_function int_add {
			0,	//name
			{	//default values
				nullptr,
				nullptr,
				nullptr
			}
		};
		float_add_function float_add {
			0,
			{
				nullptr,
				nullptr,
				nullptr
			}
		};
		add_function add {
			0,	//name
			{	//defaultvalues
				nullptr,
				nullptr,
				nullptr
			},
			{	//callings
				{
					&int_add,
					{
						{0, false},
						{1, false},
						{2, false}
					}
				},
				{
					&float_add,
					{
						{0, false},
						{1, false},
						{2, false}
					}
				}
			},
			{   //valuetypes
				{
					(void*)0,
					(void*)1,
					(void*)2,
					(void*)3
				},
				{
					(void*)0,
					(void*)1,
					(void*)2,
					(void*)3
				},
				{
					(void*)0,
					(void*)1,
					(void*)2,
					(void*)3
				}
			},
			nullptr //&mux
		};
		//(-)
		int_sub_function int_sub {
			0,
			{
				nullptr,
				nullptr,
				nullptr
			}
		};
		float_sub_function float_sub {
			0,
			{
				nullptr,
				nullptr,
				nullptr
			}
		};
		//(*)
		int_mul_function int_mul {
			0,
			{
				nullptr,
				nullptr,
				nullptr
			}
		};
		float_mul_function float_mul {
			0,
			{
				nullptr,
				nullptr,
				nullptr
			}
		};
		//(/)
		int_div_function int_div {
			0,
			{
				nullptr,
				nullptr,
				nullptr
			}
		};
		float_div_function float_div {
			0,
			{
				nullptr,
				nullptr,
				nullptr
			}
		};
		//(%)
		//function vector
		std::vector<basicfunction*>* functions = new std::vector<basicfunction*>(
			{
				&int_add,
				&float_add,
				&add,
				&int_sub,
				&float_sub,
				&int_mul,
				&float_mul,
				&int_div,
				&float_div
			}
		);
		std::vector<basicfunction*>* getfunctions() {
			return functions;
		}
	}
}

код add.cpp
#include "pch.h"
#include "add.h"
namespace functions {
	namespace algebra {
		void int_add_function::execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream) {
			std::vector<void*> values;
			filldefaultvalues(argumentspointer, &values);
			if (values[2] && values[1] && values[0]) {
				if (!errorcodepointer || forced) {
					*(int*)values[2] = *(int*)values[0] + *(int*)values[1];
				}
			}
			else if (errorcodepointer) {
				*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
			}
		}
		void float_add_function::execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream) {
			std::vector<void*> values;
			filldefaultvalues(argumentspointer, &values);
			if (values[2] && values[1] && values[0]) {
				if (!errorcodepointer || forced) {
					*(float*)values[2] = *(float*)values[0] + *(float*)values[1];
				}
			}
			else if (errorcodepointer) {
				*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
			}
		}
		//(-)
		void int_sub_function::execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream) {
			std::vector<void*> values;
			filldefaultvalues(argumentspointer, &values);
			if (values[2] && values[1] && values[0]) {
				if (!errorcodepointer || forced) {
					*(int*)values[2] = *(int*)values[0] - *(int*)values[1];
				}
			}
			else if (errorcodepointer) {
				*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
			}
		}
		void float_sub_function::execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream) {
			std::vector<void*> values;
			filldefaultvalues(argumentspointer, &values);
			if (values[2] && values[1] && values[0]) {
				if (!errorcodepointer || forced) {
					*(float*)values[2] = *(float*)values[0] - *(float*)values[1];
				}
			}
			else if (errorcodepointer) {
				*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
			}
		}
		//(*)
		void int_mul_function::execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream) {
			std::vector<void*> values;
			filldefaultvalues(argumentspointer, &values);
			if (values[2] && values[1] && values[0]) {
				if (!errorcodepointer || forced) {
					*(int*)values[2] = *(int*)values[0] * *(int*)values[1];
				}
			}
			else if (errorcodepointer) {
				*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
			}
		}
		void float_mul_function::execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream) {
			std::vector<void*> values;
			filldefaultvalues(argumentspointer, &values);
			if (values[2] && values[1] && values[0]) {
				if (!errorcodepointer || forced) {
					*(float*)values[2] = *(float*)values[0] * *(float*)values[1];
				}
			}
			else if (errorcodepointer) {
				*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
			}
		}
		//(/)
		void int_div_function::execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream) {
			std::vector<void*> values;
			filldefaultvalues(argumentspointer, &values);
			if (values[2] && values[1] && values[0]) {
				if (*(int*)values[1] == 0) {
					if (errorcodepointer) {
						*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
					}
					return;
				}
				if (!errorcodepointer || forced) {
					*(int*)values[2] = *(int*)values[0] / *(int*)values[1];
				}
			}
			else if (errorcodepointer) {
				*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
			}
		}
		void float_div_function::execute(std::vector<void*>* argumentspointer, uint64_t* errorcodepointer, bool forced, void* stream) {
			std::vector<void*> values;
			filldefaultvalues(argumentspointer, &values);
			if (values[2] && values[1] && values[0]) {
				if (!errorcodepointer || forced) {
					*(float*)values[2] = *(float*)values[0] / *(float*)values[1];
				}
			}
			else if (errorcodepointer) {
				*errorcodepointer = 2; //change errorcode: error: can`t operate nullptr
			}
		}
	}
}

код main.h
#pragma once
#include "add/add.h" //error 2005
#include "pch.h"
namespace ns {
	void funcs() {}
}

код pch.h
#pragma once
#ifndef PCH_H
#define PCH_H
#include "framework.h"
#include "function/include/functionfactory.h"
#endif
  • Вопрос задан
  • 130 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы