Member of dll interface class may not be declared. What does it mean?

Hello all,

I’m a bit of a novice programmer, but I’ve been at it for a bit. Currently coding a FPS game and I’m getting the title error: C2487 ‘//My Instanced Struct Name’ : member of dll interface class may not be declared.with dll interface

I know that .dll files are important, and that they have are related to the linker, but I’m not really sure what the error is saying…

The involved code is pasted below. I’d really appreciate any help that I can get with this because I’m stumped.


#pragma once

#include "GameFramework/Info.h"
#include "MonkeyNutsCharacter.h"
#include "MNWeaponInfo.generated.h"


//Specialized Information About The Weapons Found Within The Game
class MONKEYNUTS_API AMNWeaponInfo : public AInfo{

	struct Weapon{

	int32 GetMaxAmmoPool(){
		return MaxAmmoPool;
	int32 GetMaxClipSize(){
		return MaxClipSize;
	//ProjectileTypeEnum GetProjectileType();
	float GetRespawnTime(){
		return RespawnTime;

	int32 MaxAmmoPool;
	int32 MaxClipSize;
	//Projectile Type Enum
	float RespawnTime;
	static Weapon Pistol, AssaultRifle, TacRifle, Shotgun, Sniper, Rockets;
		//ProjectileType ***Need to create Enum type

		//The Maximum Clip Size of weapons of this type.
		UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponInfo)
		int32 MaxClip;
		//The Maximum Ammo Pool that can be associated with weapons of this type
		UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponInfo)
		int32 MaxAmmoPool;
		//Location (relative to the character model) at which the projectiles for this weapon will spawn.
		UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponInfo)
		FVector ProjectileSpawnOffset;
		//Location of this weapon type (when equipped) relative to the character model
		UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponInfo)
		FVector WeaponOffSetFromPlayer;



#include "MonkeyNuts.h"
#include "MNWeaponInfo.h"

AMNWeaponInfo::AMNWeaponInfo(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
	Pistol.MaxAmmoPool = 40;


SUBSET of MonkeyNutsCharacter.cpp

#include "MonkeyNuts.h"
#include "WeaponTypes.h"
#include "MNWeaponPickup.h"
#include "MonkeyNutsCharacter.h"
#include "Math.h"
#include "MNWeaponInfo.h"

AMonkeyNutsCharacter::AMonkeyNutsCharacter(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP.SetDefaultSubobjectClass<UMNCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))
{//insert other class stuff here}

void AMonkeyNutsCharacter::PickUpWeapon(AMNWeaponPickup* WeaponPU){
	TEnumAsByte<EWeaponTypes::Type> PUWeaponType = WeaponPU->GetWeaponType();
	int32 PUClipMaxSize = 0;
	int32 PUMaxAmmoPool = 0;
	switch (PUWeaponType)
	case EWeaponTypes::Pistol:
	PUClipMaxSize = AMNWeaponInfo::Pistol.GetMaxClipSize();
	PUMaxAmmoPool = AMNWeaponInfo::Pistol.GetMaxAmmoPool();
	case EWeaponTypes::AssaultRifle:
	PUClipMaxSize = AMNWeaponInfo::AssaultRifle.GetMaxClipSize();
	PUMaxAmmoPool = AMNWeaponInfo::AssaultRifle.GetMaxAmmoPool();
	case EWeaponTypes::TacRifle:
	PUClipMaxSize = AMNWeaponInfo::TacRifle.GetMaxClipSize();
	PUMaxAmmoPool = AMNWeaponInfo::TacRifle.GetMaxAmmoPool();
	case EWeaponTypes::Shotgun:
	PUClipMaxSize = AMNWeaponInfo::Shotgun.GetMaxClipSize();
	PUMaxAmmoPool = AMNWeaponInfo::Shotgun.GetMaxAmmoPool();
	case EWeaponTypes::Sniper:
	PUClipMaxSize = AMNWeaponInfo::Sniper.GetMaxClipSize();
	PUMaxAmmoPool = AMNWeaponInfo::Sniper.GetMaxAmmoPool();
	case EWeaponTypes::Rockets:
	PUClipMaxSize = AMNWeaponInfo::Rockets.GetMaxClipSize();
	PUMaxAmmoPool = AMNWeaponInfo::Rockets.GetMaxAmmoPool();
	case EWeaponTypes::Unarmed:
	int32 PUAmmoInClip = WeaponPU->GetAmmoInClip();
	int32 PUAmmoPool = WeaponPU->GetAmmoPool();

	int32 OutGoingAmmoInClip = Equipped_AmmoClip_Remaining;
	int32 OutGoingAmmoPool = Equipped_Ammo_Remaining;
	TEnumAsByte<EWeaponTypes::Type> OutGoingWeaponType = GetEquippedWeapon();
	EquippedWeapon = PUWeaponType;
	Equipped_AmmoClip_Remaining = PUAmmoInClip;
	Equipped_Ammo_Remaining = PUAmmoPool;
	Equipped_AmmoClip_Max = PUClipMaxSize;

I believe you have come across a bug in the compiler. It happens when you have declared multiple static variables on one line. You can get around it by putting each of your static vars on a separate line. So in your case, instead of:

static Weapon Pistol, AssaultRifle, TacRifle, Shotgun, Sniper, Rockets;

You would do:

static Weapon Pistol;
static Weapon AssaultRifle;
static Weapon TacRifle; 
static Weapon Shotgun;
static Weapon Sniper;
static Weapon Rockets;

For anyone interested, here is the link to the bug report:

Hello Guys, Thanks for the response. This resolved the first issue that I had, but now I have an LNK2001 error for each instantiated struct. Any ideas?

The most likely reason is that you haven’t initialized your static variables. In your .cpp you will need to do something like this for each of your statics:

 AMNWeaponInfo::Weapon AMNWeaponInfo::Pistol = {0};