Subject: Re: XCreateSimpleWindow and SIGSEGV
From: [email-masked] (Earnie Boyd)

16 May 1998 06:22:41 -0700
Message-ID: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
To: Glynn Leo <[email-masked]>, [email-masked]

Your welcome, Glynn,

I've found that SIGSEGV occurs most often, at least for me, when I'm
passing pointers to non-pointers or vice versa.

Use the -Wall switch and take a look at the warnings.

---Glynn Leo <[email-masked]> wrote:
>
> Thanx to Earnie 
> I've got my program Compiling 
> I found that XCreateSimpleWindow is giving me 
> SIGSEGV fault Anyone have the same problem
> Have compiled with mmalloc,downloaded the Latest Binaries on NT
> and search archives but to no avail
> Also have X-Server and DISPLAY set
> (Do get the warning message 
>     WinMainCRTStartup ; defaulting to 00401000 )
> 
> Anyone see any problem with the following ?
> thanx
> leo
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <X11/Xlib.h>
> #include <X11/Xutil.h>
> #include <X11/Xatom.h>
> #include "Xstuff.h"
> #include <string.h>
> #include <X11/Xlib.h>
> #include <X11/Xutil.h>
> 
> typedef struct S_window
> {
>   Display*  pDisplay;
>   int       screen;
>   Window    window;
>   GC        gc;
>   int       imageWidth;
>   int       imageHeight;
>   XImage*   pImage;
>   char*     pImageData;
>   XImage*   pSinglePixelImage;
>   Colormap  colorMap;
> } tSwindow;
> 
> 
> tSwindow*
> ScreateWindow(char*  pWindowName, char*  pDisplayName,
> int imageWidth, int imageHeight);
> 
> #define  IMAGE_WIDTH 360
> #define  IMAGE_HEIGHT 240
>  
>  
> main()
>  
> {
>   tSwindow*  pWindow;
>  
>   pWindow = ScreateWindow("rgb_test",
>                             ":0.0",
>                             IMAGE_WIDTH,
>                             IMAGE_HEIGHT);
>  
> }
>  
>  
> tSwindow*
> ScreateWindow(char*  pWindowName,
>                 char*  pDisplayName,
>                 int imageWidth, int imageHeight
>                 )
> {
>   tSwindow*  pReturnValue;
>   XGCValues    gcValues;
>   char*        pWindowBanner;
>  
>   pReturnValue = (tSwindow*)malloc(sizeof(tSwindow));
>  
>  
>   /* Try to connect to the X server */
>   pReturnValue->pDisplay = XOpenDisplay(":0.0");
>   if (pReturnValue->pDisplay == NULL)
>   {
>       free(pReturnValue);
>       return(NULL);
>   }
>  
>   pReturnValue->screen = DefaultScreen(pReturnValue->pDisplay);
>  
>   /* Now, create the window */
>   /* It seems RootWindow() is causing the SIGSEGV */
>   pReturnValue->window =
>         XCreateSimpleWindow(pReturnValue->pDisplay,
>                         RootWindow(pReturnValue->pDisplay,
>                                    pReturnValue->screen),
>                             300,
>                             300,
>                         imageWidth, imageHeight,
>                         4,
>                         BlackPixel(pReturnValue->pDisplay,
>                                    pReturnValue->screen),
>                         WhitePixel(pReturnValue->pDisplay,
>                                    pReturnValue->screen));
> }
>  
>  
> 
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
> -
> For help on using this list (especially unsubscribing), send a
message to
> "[email-masked]" with one line of text: "help".
> 

==
-        \\||//
---o0O0--Earnie--0O0o----
[email-masked]
------ooo0O--O0ooo-------

_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".