CUDA Error : identifier is undefined

I been struggling for hours to figure out what is wrong. It says the Class “Neuron” is undefined in, but it is included right at the top. I’m using VS2013, and a CUDA v7.5 Project. Is it the fact that their are “Neuron” object pointers in, along with “Synapse” object pointers in

Here is the Error:
error : identifier “Neuron” is undefined in

Thank you for the help,
Andrew :


#include "cuda_runtime.h"
#include ""
using namespace std;

#define CUDA_CALLABLE_MEMBER __host__ __device__

class Synapse
	// Foward Prop.
	double _weight;
	// Back Prop.
	double _weightDelta;
	Neuron* _outputNeuron;          // This is the Line where the Error occured
	Neuron* _inputNeuron;

	// Constructor
	// Destructor

#endif :

#ifndef NEURONH_CU
#define NEURONH_CU

#include "cuda_runtime.h"
#include ""
#include ""
using namespace std;

#define CUDA_CALLABLE_MEMBER __host__ __device__

class Neuron
	typedef Synapse* SynapsePtr;
	// Ctr For Neuron in Network
	int _neuronCtr;
	// Output & Inputs Synapses
	Synapse* _outputSynapses;
	SynapsePtr* _inputSynapses = nullptr;
	int _outputSynapsesLen, _inputSynapsesLen;
	// Neuron Weights
	double m_bias;
	double _biasDelta;
	// Input
	double _input;
	// Output
	double m_output;
	// BackProp: Gradiant
	double _gradiant;
	// Ptr ActivationFunc

	ActivationFunc* _actvFunc = nullptr;


	// Constuctor
	// Destructor

	// Creates Construct
	CUDA_CALLABLE_MEMBER void createNeuron(int numNeuronsNextLayer);

	// Setters
	// Sets Output & Weighted Output (m_wtdOutput)
	CUDA_CALLABLE_MEMBER void setOutput(double output) { m_output = output; }
	// Ini. / Puts together _inputSynapse*[]
	CUDA_CALLABLE_MEMBER void iniInputSynapse(int numInputSynapse);
	// Save the Pointer to the ActivationFunc.
	CUDA_CALLABLE_MEMBER void Neuron::setActvFunc(ActivationFunc* actvFunc);

	// Gets the Output Multiplied by the Weights
	// <param name="NeuronIdx">The index of the Neuron at the Layer being Calc. 
        // Wants the Synapse info to put in its Input.</param>
	// <returns>Synapse Output from the NeuronIdx</returns>
	CUDA_CALLABLE_MEMBER double getSynapseOutput(int NeuronIdx);

	// BackProp: Calc Error
	CUDA_CALLABLE_MEMBER double calcError(double* target);

1 Like

Hi Andrew (a.k.a. supracharger),
I am new to CUDA & VisualStudio, but I see you including .cu files, but I was taught that .h files should be included and .cu files are linked.
But never mind that, the problem starts at the first line of
When compiles it defines (line 2) NEURONH_CU, then includes (line 5)
…When is included, at line 5 it tries to include, but since NEURONH_CU is defined nothing is included.
…Then in (Line20) declares _outputNuron as a pointer to Neuron, which is not yet defined.

I believe the problem is that your definitions are dependent on each other.

It has been a while since I programmed in C++ so I don’t know how to get around the problem of dependent definitions.

I think you will have to create Parent Virtual classes for ‘synapase’ and ‘neuron’ without the dependency.
For now call these classes ‘SynapseVC’ and ‘NeuronVC’
Then your definitions (class statements) for for Neuron and Synapse would define variables to these Parent Virtual classes.
your Neuron class will inherent from NeuronVC and your Synapse class will inherent from SynapaseVC.

I suspect that you might be a Python programmer as the code you created might be valid there, but not here?

I hope this helps.


OOPS I mis-spoke, please consider my use of the term ‘definitions’ incorrect, I should have used the term ‘decelerations’.

So the line should read:
… “I believe the problem is that your decelerations are dependent on each other.”

circular inclusion.


#include ""


class Neuron;

Thanks for the support guys!

Chuck, thank you for a good explaination to what is happening, and I’m not a Python coder, but going back to C++ from C# mainly.

episteme, thank you for the easier fix.

The file “” was suppose to be the header file since I can’t use the .h extension because it needs to run through the CUDA compiler. However, I figured out that .cuh extension is for a CUDA header file.

I found that using the quick class declaration with the include the header file worked best because I was getting empty class errors.

class Neuron;
#include "Neuron.cuh"    // Changed Ext.
  • Andrew