Comments (9)
Should also note that this also creates a slew of compiler warnings.
from raygui.
It should probably be redesigned...
from raygui.
I don't think it would be too hard to keep the definitions in the header, and build a library for the actual implementation.
This would break the header only design, but in the long run might be more maintainable.
This would also follow what raylib does.
from raygui.
@smalls12 I redesigned the functions definition settings in commit 09d5836.
Now it should work as expected:
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
//#define RAYGUI_STATIC // Only if you want to keep raygui functionality internal to current module
#include "raygui.h"
from raygui.
Okay appears to be working now.
I do get the following warning though.
In file included from /src/scratch/blokus/src/StartScreen.cpp:3:0:
/src/staging/usr/include/raygui.h:144:0: warning: "RAYGUIDEF" redefined
#define RAYGUIDEF extern "C" // Functions visible from other files (no name mangling of functions in C++)
/src/staging/usr/include/raygui.h:137:0: note: this is the location of the previous definition
#define RAYGUIDEF // We are building or using raygui as a static library (or Linux shared library)
from raygui.
Yeah, I simplified the conditions to work better but it involved redefining the define when required.
from raygui.
Hi, i'm commenting on this closed issue since i'm having a similar problem with the original comment.
Like in the first comment, i'm developing a C++ application where i wrap all the different raygui elements into it's own class (I'm a beginner so sorry if this is a very stupid questions).
I'm downloading the latest raylib version using CMake
FetchContent_Declare(
raylib
GIT_REPOSITORY "https://github.com/raysan5/raylib.git"
GIT_TAG "master"
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(raylib)
and i have copied both the raylib and the raygui header files into a folder in my project i called include
.
Than in my main file (main.cpp
) i have
#include "./include/raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "./include/raygui.h"
#include "./include/button.hpp"
and in my button.h
#include "./raylib.h"
#include "./raygui.h"
The error i'm getting is
In file included from /Users/lorenzo/Developer/battaglia_navale/src/main.cpp:7:
In file included from /Users/lorenzo/Developer/battaglia_navale/src/./include/button.hpp:6:
/Users/lorenzo/Developer/battaglia_navale/src/./include/raygui.h:1072:21: error: redefinition of 'guiIcons'
static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] = {
Looking at the raygui.h
file i can see the problem, there are parts of code that are not guarded from multiple inclusions. Am i misinterpreting the warning
NOTE: raygui is a single-file header-only library (despite its internal dependency on raylib), so, functions definition AND implementation reside in the same file raygui.h, when including raygui.h in a module, RAYGUI_IMPLEMENTATION must be previously defined to include the implementation part of raygui.h BUT only in one compilation unit, other modules could also include raygui.h but RAYGUI_IMPLEMENTATION must not be defined again.
in the raygui README?
from raygui.
@daidalo-s The solution I use for those cases is:
#include "./include/raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "./include/raygui.h"
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
from raygui.
Thanks a lot! This worked!
from raygui.
Related Issues (20)
- Resize without interpolation
- Cursor was missing when compiled in PLATFORM_DRM when using raygui. HOT 1
- Calling GuiLoadStyle() with enefete/sunny causes assertion fail in raylib HOT 1
- `GuiColorBarHue` bug when selecting a color HOT 5
- `GuiToggle()` always returns 0 HOT 6
- Multiple `GuiTextInputBox()` not supported HOT 2
- [`rGuiStyler`] Support for substepping font rasterization HOT 3
- examples build issue HOT 1
- `GuiButton()` not considering mouse state as exclusive mode HOT 2
- Dynamic depth management HOT 4
- Input blocking / input event consuming HOT 2
- [Feature Request] Keyboard Navigation HOT 2
- Error - cannot convert bool* to int* HOT 1
- [Feature Request] Accessibility support? HOT 5
- Problem with Installation HOT 1
- Problem when define HOT 2
- Documentation on the `rgs` format HOT 2
- Issue with Unicode input on `GuiTextBox()` HOT 1
- Compile for Rapberry Pi 2B HOT 3
- Raspberry Pi - touch does not works. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raygui.