This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: XCreateSimpleWindow and SIGSEGV


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 <lglynn@hotmail.com> 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
> "gnu-win32-request@cygnus.com" with one line of text: "help".
> 

==
-        \\||//
---o0O0--Earnie--0O0o----
--earnie_boyd@yahoo.com--
------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
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]