Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Visual Micro does not compile, arduino ide does (Read 1026 times)
PORTB
Newbies
*
Offline


Posts: 1
Joined: Jul 26th, 2018
Visual Micro does not compile, arduino ide does
Jul 26th, 2018 at 10:10am
Print Post  
Hello, I am having problems compiling this code:
Code (C++)
Select All
struct ChannelBlender
{
public:
	virtual uint8_t blend(uint8_t A, uint8_t B)
	{
		return 0;
	}

	uint32_t blend(uint32_t A, uint32_t B)
	{
		return blend(A & 0xff0000 >> 10, B & 0xff0000 >> 10) << 10 | blend(A & 0xff00 >> 8, B & 0xff0000 >> 8) << 8 | blend(A & 0xff, B & 0xff);
	}
};

uint32_t thingy(ChannelBlender something)
{
	//....
	return 23;
}

void setup()
{


}

void loop()
{


} 



It is giving me the errors:
Code
Select All
test__.ino: 9:17: error: 'ChannelBlender' was not declared in this scope
   public

Error compiling .ino project source
test__.ino: In function uint32_t thingy(ChannelBlender)
Debug build failed for project 'test__'

test__.ino: 21:41: error: 'uint32_t thingy(ChannelBlender)' redeclared as different kind of symbol
   uint32_t thingy(ChannelBlender something)

test__.ino: 9:10: error: previous declaration of 'uint32_t thingy
   public 


However, arduino ide (and other ides) compile fine.
Why is this happening?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Visual Micro does not compile, arduino ide does
Reply #1 - Jul 26th, 2018 at 3:33pm
Print Post  
The arduino ide will make function prototypes with user defined structs under some conditions but not all. 

Visual Micro leaves you to add them where and when applicable which is somewhere between where the type if defined and where the function is defined. I have added a prototype for you in the code below.

note: When using cpp/h files you always need to add your own prototypes so it is a good thing to learn. Prototypes are exact same definition as the function signature with ; on the end


Code
Select All
struct ChannelBlender
{
public:
	virtual uint8_t blend(uint8_t A, uint8_t B)
	{
		return 0;
	}

	uint32_t blend(uint32_t A, uint32_t B)
	{
		return blend(A & 0xff0000 >> 10, B & 0xff0000 >> 10) << 10 | blend(A & 0xff00 >> 8, B & 0xff0000 >> 8) << 8 | blend(A & 0xff, B & 0xff);
	}
};

uint32_t thingy(ChannelBlender something);

uint32_t thingy(ChannelBlender something)
{
	//....
	return 23;
}

void setup()
{


}

void loop()
{


}  

  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint