-
Notifications
You must be signed in to change notification settings - Fork 87
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
Become C++-friendly #16
base: master
Are you sure you want to change the base?
Conversation
Hi Madera, I am currently looking for a tray library like this but I'm using C++, how is your fork going? |
Hey there, @KaiH-0 ! I made the code that is on this branch, and never touched it again. It's working, so basically the definition of "no news is good news". This is not surprising, considering that the API was created before 1995 :) |
Ahh okay, thanks for confirming, I did try your branch as well. I'm guessing its because the code would take so much time to upgrade for modern c++? Thanks for answering. |
Well, since this project isn't mine, I just created the minimum acceptable patch as a PR to be usable with C++. Without this patch the C++ compiler will just get angry at you. In order to make it "modern" we would need to kill C support and a good rewrite (which would demand time) introducing breaking changes, resulting in a PR that would change 80+% of the project. That would not be a patch anymore. Anyway, since this does the job and lives well with plain C, I don't see a need for such an endeavor, unless it's purely for fun! XD |
How do you use your C++ patch? As I may of done it wrong. I still seem to get errors when using the code from the example on the readme.md and also get errors if I use the code from example.c in a cpp file, is there anyway to use it in a cpp file? |
Let me extract the code portion that uses it. In 24 hours max I'll post it here for you. In the meantime, what errors are you getting? |
Thank you so much! Also here are the errors I'm getting: This is from using the tray.h file and taking the example from the readme.md |
Is using /std:c++latest not an option? |
That worked! The only error I have now is: tray_update(&tray); |
Make sure you are including the tray.h on the top of the example file. Your compiler might be confusing the type instance (struct tray tray) with the type (struct type). In order to avoid confusion, rename the tray type to something like "windows_tray", "tray_type", or whatever else you like. Or rename the instance itself, going from "struct tray tray" to "struct tray my_tray" or something. EDIT: We are going C++-only, so remove the struct from the type. Also, you might consider making it clear:
becomes:
|
That's a problem outside of the library, I'm afraid. |
struct tray_menu menus[] = { I think it means this isn't declared. |
Remove struct from the statement, since you are using C++. Same for all other typedefs. |
Edited previous comment for clarity. |
struct tray_menu menus[] = { ::tray tray = { void toggle_cb(struct tray_menu *item) { void quit_cb(struct tray_menu *item) { In this layout it works fine except it can't find toggle_cb and quit_cb. And I'm not quite sure why. But if I place them above tray_menu menus[], then the tray_update(&tray) is illegal. |
Add a declaration of the functions on the top:
|
That worked! Thank you so much! I can finally use this in my project! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be merged!
Set of commits to allow C++ programs to use the library, while simplifying and securing minor code points.