achimdoebler / UGUI

µGUI - Open Source GUI module for embedded systems
Other
1.2k stars 415 forks source link

Arduino Compile Issue #45

Open niradat opened 3 years ago

niradat commented 3 years ago

Hi, Following is my code on Arduino IDE using ATMEGA2560 Board. `#include

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 commented 3 years ago

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 commented 3 years ago

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

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 functionsetup':

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`