LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-12-2018, 11:25 AM   #1
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,397

Rep: Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238
C++ from C xmp.h function call: XpmCreatePixmapFromData


I am writing this little dockapp in C++ converting what I can from C using the, if you've heard of it, wmgeneral.c file to help create the dockapp window.

within it are a bunch of hand written functions that where using
Code:
char *something = "whatever";
getting,
Code:
 ISO C++ forbids converting a string constant to 'char*'
so I changed everything to
Code:
char const *something = " whatever";
starting from the xpm file and modding it to this within the file.
Code:
static char const * bgmask_xpm[] = {

now I have an outside function call coming from xmp.h called.
Code:
 FUNC(XpmCreatePixmapFromData, int, (Display *display,
					Drawable d,
					char **data,
					Pixmap *pixmap_return,
					Pixmap *shapemask_return,
                                        XpmAttributes *attributes));
https://github.com/winlibs/libxpm/bl...lude/X11/xpm.h

how do I get that function to conform from a char **data to a char const **data without having to re-code their code?

I'm getting this
Code:
/home/userx/C++Projects/wmslideshow/wmgeneral.cpp|178|error: invalid conversion from 'const char**' to 'char**' [-fpermissive]|
/usr/include/X11/xpm.h|292|note:   initializing argument 3 of 'int XpmCreatePixmapFromData(Display*, Drawable, char**, Pixmap*, Pixmap*, XpmAttributes*)'|
which is the last error I got to get rid of before I can move on with this little endeavor.



( though I seen it pop open the header in codeblocks to show me what it's talking about. -- MAYBE just edit that one add const into its definition and cross my fingers? )

Last edited by BW-userx; 04-12-2018 at 11:27 AM.
 
Old 04-12-2018, 11:45 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,397

Original Poster
Rep: Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238
UPDATE: casting didn't work...
Code:
 err = XpmCreatePixmapFromData(display, Root, (char **)pixmap_bytes, &(wmgen->pixmap), &(wmgen->mask), &(wmgen->attributes));
Code:
||=== Build: Debug in wmslideshow (compiler: GNU GCC Compiler) ===|
||error: ld returned 1 exit status|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
 
Old 04-12-2018, 11:46 AM   #3
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 788

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
Here you go: http://en.cppreference.com/w/cpp/language/const_cast
 
1 members found this post helpful.
Old 04-12-2018, 12:46 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,397

Original Poster
Rep: Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238
Quote:
Originally Posted by norobro View Post
I'm assuming this is correct, I got a good compile, with a seg fault, that shows progress.
Code:
static void GetXPM(XpmIcon *wmgen, char const *pixmap_bytes[]) {

    XWindowAttributes   attributes;
    int                 err;

    char **pixmapy = const_cast<char **>(pixmap_bytes);

   // For the colormap
    XGetWindowAttributes(display, Root, &attributes);

    wmgen->attributes.valuemask |= (XpmReturnPixels | XpmReturnExtensions);

    err = XpmCreatePixmapFromData(display, Root, pixmapy /*  pixmap_bytes */, &(wmgen->pixmap), &(wmgen->mask), &(wmgen->attributes));

    if (err != XpmSuccess) {
        fprintf(stderr, "Not enough free colorcells.\n");
        exit(1);
    }
}
just got to weed out the seg fault now. Hopefully its nothing to do with the changes I made to the char to const char.

Last edited by BW-userx; 04-12-2018 at 12:47 PM.
 
Old 04-12-2018, 12:57 PM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,397

Original Poster
Rep: Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238Reputation: 1238
Got it! onward and upwards...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
issue with function or call to function sysmicuser Linux - Newbie 5 06-02-2016 09:25 AM
[SOLVED] read function call returning more amount of data than wiritten using write function chakka.lokesh Programming 1 09-11-2014 03:14 AM
[SOLVED] g++ error message no matching function for call to some function Jerry Mcguire Programming 6 04-13-2010 08:37 PM
[SOLVED] Threaded function cannot call a function with extern "C" but nonthreaded function can morty346 Programming 16 01-12-2010 05:00 PM
Compilation issue when Function is parameter in function call on LINUX sa20358 Linux - Software 2 07-24-2008 10:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration