Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Compile Issue #45

Open
niradat opened this issue Jul 1, 2021 · 2 comments
Open

Arduino Compile Issue #45

niradat opened this issue Jul 1, 2021 · 2 comments

Comments

@niradat
Copy link

niradat commented Jul 1, 2021

Hi,
Following is my code on Arduino IDE using ATMEGA2560 Board.
`#include <SPI.h>
#include "ugui.h"
#include "ugui_config.h"

#define DISPLAY_WIDTH 160
#define DISPLAY_HEIGHT 128

#define MAX_OBJECTS 10
#define BuffOUT 40

char bufferOut[BuffOUT];
void window_1_callback(UG_MESSAGE *msg);
UG_GUI gui1963;
UG_COLOR color[3];

void my_int_func(UG_S16 x,UG_S16 y,UG_COLOR z)
{
unsigned int sum=0;
sum=x+y+z;
}

void setup()
{
void (*foo)(UG_S16,UG_S16,UG_COLOR);
foo = &my_int_func;

UG_Init(&gui1963, foo(2,2,3), 160, 128); 

UG_COLOR color[3];        
UG_WINDOW window_1;
UG_BUTTON button_1;
UG_BUTTON button_2;
UG_BUTTON button_3;
UG_TEXTBOX textbox_1;
UG_OBJECT obj_buff_wnd_1[MAX_OBJECTS];

UG_Init(&gui1963, foo(2,2,3), 160, 128);    

}

void loop()
{
// put your main code here, to run repeatedly:

}`

I encounter following error when compiling. Kindly provide an insight of whats going wrong?

testugui:27:43: error: invalid use of void expression

 UG_Init(&gui1963, foo(2,2,3), 160, 128);
                                       ^

testugui:37:43: error: invalid use of void expression

 UG_Init(&gui1963, foo(2,2,3), 160, 128);

Regards,

@0x3333
Copy link

0x3333 commented Jul 1, 2021

You are calling UG_Init calling foo, you should pass foo as parameter , not calling it.

UG_Init(&gui1963, &my_int_func, 160, 128);

@niradat
Copy link
Author

niradat commented Jul 1, 2021

Hello 0x3333,
Same error persist even when the function is passed as parameter. Kindly check this code. I have made it more simple.
`#include <SPI.h>
#include "ugui.h"
#include "ugui_config.h"

#define DISPLAY_WIDTH 160
#define DISPLAY_HEIGHT 128

#define MAX_OBJECTS 10
#define BuffOUT 40

char bufferOut[BuffOUT];
void window_1_callback(UG_MESSAGE *msg);

UG_GUI gui1963;
UG_COLOR color[3];

void my_int_func(UG_S16 x,UG_S16 y,UG_COLOR z)
{
unsigned int sum=0;
sum=x+y+z;
}

void setup()
{
UG_Init(&gui1963, &my_int_func , 160, 128);

UG_COLOR color[3];        
UG_WINDOW window_1;
UG_BUTTON button_1;
UG_BUTTON button_2;
UG_BUTTON button_3;
UG_TEXTBOX textbox_1;
UG_OBJECT obj_buff_wnd_1[MAX_OBJECTS];    

}

void loop()
{
// put your main code here, to run repeatedly:

}`

Following error is encountered.

C:\Users\User\AppData\Local\Temp\ccxbkPNw.ltrans0.ltrans.o: In function setup':

C:\Users\User\Desktop\testugui/testugui.ino:25: undefined reference to `UG_Init(UG_GUI*, void (*)(int, int, unsigned int), int, int)'

collect2.exe: error: ld returned 1 exit status`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants