Hi Pelle,
I've spent several hours testing RC3 ... things are looking very good.
However, I am getting the following compile error on a small sample that has
always compiled and executed fine with earlier versions of Pelles C. It currently
compiles and executes fine using several other compilers.
graph.c(310): fatal error: Internal error: spill_at_range()Here is the complete source code:
// *********************************************************************
// Created with BCX32 - BASIC To C/C++ Translator (V) 6.2.2 (2010/10/24)
// BCX (c) 1999 - 2009 by Kevin Diggins
// *********************************************************************
// Translated for compiling with a C Compiler
// *********************************************************************
#include <windows.h> // Win32 Header File
#include <windowsx.h> // Win32 Header File
#include <commctrl.h> // Win32 Header File
#include <commdlg.h> // Win32 Header File
#include <mmsystem.h> // Win32 Header File
#include <shellapi.h> // Win32 Header File
#include <shlobj.h> // Win32 Header File
#include <richedit.h> // Win32 Header File
#include <wchar.h> // Win32 Header File
#include <objbase.h> // Win32 Header File
#include <ocidl.h> // Win32 Header File
#include <winuser.h> // Win32 Header File
#include <olectl.h> // Win32 Header File
#include <oaidl.h> // Win32 Header File
#include <ole2.h> // Win32 Header File
#include <oleauto.h> // Win32 Header File
#include <conio.h>
#include <direct.h>
#include <ctype.h>
#include <io.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <setjmp.h>
#include <time.h>
#include <stdarg.h>
#include <process.h>
// ***************************************************
// Compiler Defines
// ***************************************************
// C++
#if defined( __cplusplus )
#define overloaded
#define C_EXPORT EXTERN_C __declspec(dllexport)
#define C_IMPORT EXTERN_C __declspec(dllimport)
#else
#define C_EXPORT __declspec(dllexport)
#define C_IMPORT __declspec(dllimport)
#endif
// Open Watcom defs
#if defined( __WATCOM_CPLUSPLUS__ ) || defined( __TINYC__ )
#define atanl atan
#define sinl sin
#define cosl cos
#define tanl tan
#define asinl asin
#define acosl acos
#define log10l log10
#define logl log
#define _fcloseall fcloseall
#endif
// Borland C++ 5.5.1 defs - bcc32.exe
#if defined( __BCPLUSPLUS__ )
// ===== Borland Libraries ==========
#include <dos.h>
#pragma comment(lib,"import32.lib")
#pragma comment(lib,"cw32.lib")
// ==================================
#endif
// Microsoft VC++
#ifndef DECLSPEC_UUID
#if (_MSC_VER >= 1100) && defined ( __cplusplus )
#define DECLSPEC_UUID(x) __declspec(uuid(x))
#else
#define DECLSPEC_UUID(x)
#endif
#endif
#if !defined( __LCC__ )
// *************************************************
// Instruct Linker to Search Object/Import Libraries
// *************************************************
#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"user32.lib")
#pragma comment(lib,"gdi32.lib")
#pragma comment(lib,"comctl32.lib")
#pragma comment(lib,"advapi32.lib")
#pragma comment(lib,"winspool.lib")
#pragma comment(lib,"shell32.lib")
#pragma comment(lib,"ole32.lib")
#pragma comment(lib,"oleaut32.lib")
#pragma comment(lib,"uuid.lib")
#pragma comment(lib,"odbc32.lib")
#pragma comment(lib,"odbccp32.lib")
#pragma comment(lib,"winmm.lib")
#pragma comment(lib,"comdlg32.lib")
#pragma comment(lib,"imagehlp.lib")
#pragma comment(lib,"version.lib")
#else
#pragma lib <winspool.lib>
#pragma lib <shell32.lib>
#pragma lib <ole32.lib>
#pragma lib <oleaut32.lib>
#pragma lib <uuid.lib>
#pragma lib <odbc32.lib>
#pragma lib <odbccp32.lib>
#pragma lib <winmm.lib>
#pragma lib <imagehlp.lib>
#pragma lib <version.lib>
// *************************************************
// End of Object/Import Libraries To Search
// *************************************************
#endif
// *************************************************
// User Defined Constants
// *************************************************
#define GRAPHPROPS_CLASS struct _GRAPHPROPS*
#define GRAPH_LEFT 0
#define GRAPH_RIGHT 1
#define CaptionName1 "BCX Graph Pseudo Control By Jeethu Rao"
#define ClassName1 "BCX_Graph"
#define ID_PUSH 1001
#define ID_FREEZE1 1002
#define ID_FREEZE2 1003
#define ID_GRAPH1 1004
#define ID_GRAPH2 1005
#define ID_TIMER1 1006
#define ID_Button1 ID_PUSH
// *************************************************
// User Defined Types And Unions
// *************************************************
typedef struct _GraphProps
{
POINT* GraphPtr;
POINT* LGraphPtr;
COLORREF GraphColor;
COLORREF GridColor;
UCHAR UpdateInterval;
UCHAR StepSize;
BOOL Frozen;
BOOL Direction;
}GraphProps, *LPGRAPHPROPS;
// *************************************************
// System Variables
// *************************************************
// *************************************************
// User Global Variables
// *************************************************
static int BCX_GetDiaUnit;
static int BCX_cxBaseUnit;
static int BCX_cyBaseUnit;
static int BCX_ScaleX;
static int BCX_ScaleY;
static int OurTimer;
static HWND Form1;
static HWND Rect1;
static HWND Rect2;
static HWND Button1;
static HWND Button2;
static HWND Button3;
// *************************************************
// Standard Macros
// *************************************************
#define DefaultFont ((BcxFont==0)?GetStockObject(DEFAULT_GUI_FONT):BcxFont)
#define BOR |
#define Show(Window)RedrawWindow(Window,0,0,0);ShowWindow(Window,SW_SHOW);
// *************************************************
// Standard Prototypes
// *************************************************
void Center (HWND,HWND=0,HWND=0);
char* BCX_TmpStr(size_t);
char* join (int, ... );
float rnd (void);
// *************************************************
// User Prototypes
// *************************************************
void InitGraph (HWND, COLORREF, COLORREF, UCHAR, BOOL);
void CloseGraph (HWND);
void FreezeGraph (HWND, int);
BOOL IsGraphFrozen (HWND);
void UpdateGraph (HWND, int, int);
void DrawGraph (HWND);
int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
void FormLoad (HINSTANCE);
// *************************************************
// User Global Initialized Arrays
// *************************************************
// *************************************************
// Runtime Functions
// *************************************************
char *BCX_TmpStr (size_t Bites)
{
static int StrCnt;
static char *StrFunc[2048];
StrCnt=(StrCnt + 1) & 2047;
if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
}
char * join(int n, ...)
{
register int i = n, tmplen = 0;
register char *s_;
register char *strtmp;
va_list marker;
va_start(marker, n); // Initialize variable arguments
while(i-- > 0)
{
s_ = va_arg(marker, char *);
if(s_) tmplen += strlen(s_);
}
strtmp = BCX_TmpStr(tmplen);
va_end(marker); // Reset variable arguments
i = n;
va_start(marker, n); // Initialize variable arguments
while(i-- > 0)
{
s_ = va_arg(marker, char *);
if(s_) strcat(strtmp, s_);
}
va_end(marker); // Reset variable arguments
return strtmp;
}
float rnd (void)
{
return (float)rand()/RAND_MAX;
}
void Center (HWND hwnd, HWND Xhwnd, HWND Yhwnd)
{
RECT rect, rectP;
int x, y, width, height;
int screenwidth, screenheight;
if(Xhwnd==0)
{
RECT DesktopArea;
RECT rc;
SystemParametersInfo(SPI_GETWORKAREA,0,&DesktopArea,0);
GetWindowRect(hwnd,&rc);
SetWindowPos(hwnd,HWND_TOP,
((DesktopArea.right-DesktopArea.left)-(rc.right-rc.left))/2+
DesktopArea.left,((DesktopArea.bottom-DesktopArea.top)-
(rc.bottom-rc.top))/2 + DesktopArea.top,0,0,SWP_NOSIZE);
return;
}
GetWindowRect (hwnd,&rect);
GetWindowRect (Xhwnd,&rectP);
width = rect.right-rect.left;
x = ((rectP.right-rectP.left)-width)/2 + rectP.left;
if(Yhwnd==NULL)
{
height = rect.bottom-rect.top;
y = ((rectP.bottom-rectP.top)-height)/2 + rectP.top;
}
else
{
GetWindowRect(Yhwnd,&rectP);
height = rect.bottom-rect.top;
y = ((rectP.bottom-rectP.top)-height)/2+rectP.top;
}
screenwidth = GetSystemMetrics(SM_CXSCREEN);
screenheight = GetSystemMetrics(SM_CYSCREEN);
if ((x<0)) x=0;
if ((y<0)) y=0;
if ((x+width>screenwidth)) x = screenwidth-width;
if ((y+height>screenheight)) y = screenheight-height;
MoveWindow (hwnd, x, y, width, height, FALSE);
}
// ************************************
// User Subs and Functions
// ************************************
void InitGraph (HWND hWnd, COLORREF GRColor, COLORREF GridColor, UCHAR StepSize, BOOL Direction)
{
GraphProps* GraphPropSet;
POINT* GPtr;
RECT rc;
VOID* LGPtr;
long lx;
GraphPropSet=(GraphProps*)malloc(sizeof(GraphProps));
GetClientRect(hWnd, &rc);
GPtr=(POINT*)malloc(sizeof(POINT)*(rc.right-rc.left/StepSize)+1);
if(Direction==GRAPH_LEFT)
{
for(lx=0; lx<=((rc.right-rc.left)/StepSize); lx+=1)
{
GPtr[lx].x=lx*StepSize;
GPtr[lx].y=rc.bottom-rc.top;
}
}
else
{
for(lx=((rc.right-rc.left)/StepSize); lx>=0; lx+=-1)
{
GPtr[lx].x=lx*StepSize;
GPtr[lx].y=rc.bottom-rc.top;
}
}
LGPtr=malloc(sizeof(POINT)*(rc.right-rc.left/StepSize)+1);
memset(LGPtr,0,sizeof(POINT)*(rc.right-rc.left/StepSize)+1);
GraphPropSet->GraphPtr=GPtr;
GraphPropSet->LGraphPtr=(LPPOINT)LGPtr;
GraphPropSet->GraphColor=GRColor;
GraphPropSet->GridColor=GridColor;
GraphPropSet->Frozen=FALSE;
GraphPropSet->StepSize=StepSize;
GraphPropSet->Direction=Direction;
SetProp(hWnd,"GraphProps",GraphPropSet);
ShowWindow(hWnd,SW_SHOW);
DrawGraph(hWnd);
}
void CloseGraph (HWND hWnd)
{
GraphProps* tmp;
VOID* DestPtr;
tmp=(GraphProps*)GetProp(hWnd,"GraphProps");
DestPtr=tmp->GraphPtr;
DestPtr=tmp->LGraphPtr;
RemoveProp(hWnd,"GraphProps");
}
void FreezeGraph (HWND hWnd, int FreezeStatus)
{
GraphProps* Gprops;
Gprops=(GraphProps*)GetProp(hWnd,"GraphProps");
if(FreezeStatus)
{
Gprops->Frozen=TRUE;
}
else
{
Gprops->Frozen=FALSE;
}
}
BOOL IsGraphFrozen (HWND hWnd)
{
GraphProps* Gprops;
Gprops=(GraphProps*)GetProp(hWnd,"GraphProps");
return Gprops->Frozen;
}
void UpdateGraph (HWND hWnd, int UpdtVal, int MaxVal)
{
RECT rc;
long WindowSizeX;
long WindowSizeY;
GetClientRect(hWnd, &rc);
WindowSizeX=rc.right-rc.left;
WindowSizeY=rc.bottom-rc.top;
POINT* pntarray;
POINT* lpointarray;
GraphProps* PropSet;
POINT* tmp_pntr1;
POINT* tmp_pntr2;
int lx;
int locSteps;
if(UpdtVal>MaxVal)
{
UpdtVal=MaxVal;
}
PropSet=(GraphProps*)GetProp(hWnd,"GraphProps");
if(PropSet->Frozen==TRUE)
{
return;
}
pntarray=PropSet->GraphPtr;
lpointarray=PropSet->LGraphPtr;
locSteps=PropSet->StepSize;
if(PropSet->Direction==GRAPH_LEFT)
{
lpointarray->y=WindowSizeY-((WindowSizeY*UpdtVal)/MaxVal);
for(lx=1; lx<=(WindowSizeX/PropSet->StepSize); lx+=1)
{
(lpointarray+lx)->y=(pntarray+(lx-1))->y;
}
for(lx=0; lx<=(WindowSizeX/PropSet->StepSize); lx+=1)
{
(pntarray+lx)->y=(lpointarray+lx)->y;
}
}
else
{
(lpointarray+(WindowSizeX/PropSet->StepSize))->y=WindowSizeY-((WindowSizeY*UpdtVal)/MaxVal);
for(lx=(WindowSizeX/PropSet->StepSize)-1; lx>=0; lx+=-1)
{
(lpointarray+lx)->y=(pntarray+(lx+1))->y;
}
for(lx=(WindowSizeX/PropSet->StepSize); lx>=0; lx+=-1)
{
(pntarray+lx)->y=(lpointarray+lx)->y;
}
}
}
void DrawGraph (HWND hWnd)
{
RECT rc;
HPEN hPen1;
HPEN hPen2;
HBITMAP MemBM;
HBITMAP OldBM;
HBRUSH black_brush;
HDC MemDC;
HDC ScreenDC;
HGDIOBJ GdiObj;
GraphProps* PropSet;
long WindowSizeX;
long WindowSizeY;
int x;
long y;
long SpacingX;
long SpacingY;
GetClientRect(hWnd, &rc);
PropSet=(GraphProps*)GetProp(hWnd,"GraphProps");
WindowSizeX=rc.right-rc.left;
WindowSizeY=rc.bottom-rc.top;
black_brush=CreateSolidBrush(RGB(0,0,0));
hPen1=CreatePen(PS_SOLID,2,PropSet->GridColor);
hPen2=CreatePen(PS_SOLID,1,PropSet->GraphColor);
ScreenDC=GetDC(hWnd);
MemDC=CreateCompatibleDC(ScreenDC);
MemBM=CreateCompatibleBitmap(ScreenDC,rc.right-rc.left,rc.bottom-rc.top);
OldBM=(HBITMAP)SelectObject(MemDC,MemBM);
FillRect(MemDC, &rc,black_brush);
SpacingX=10;
SpacingY=10;
SelectObject(MemDC,hPen1);
for(x=0; SpacingX>=0 ? x<=WindowSizeX : x>=WindowSizeX; x+=SpacingX)
{
MoveToEx(MemDC,x,0,NULL);
LineTo(MemDC,x,WindowSizeY);
}
for(y=0; SpacingY>=0 ? y<=WindowSizeY : y>=WindowSizeY; y+=SpacingY)
{
MoveToEx(MemDC,0,y,NULL);
LineTo(MemDC,WindowSizeX,y);
}
SelectObject(MemDC,hPen2);
Polyline(MemDC,PropSet->GraphPtr,(WindowSizeX/PropSet->StepSize)+1);
BitBlt(ScreenDC,rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,MemDC,0,0,SRCCOPY);
GdiObj=SelectObject(MemDC,OldBM);
ReleaseDC(hWnd,ScreenDC);
DeleteDC(MemDC);
DeleteObject(black_brush);
DeleteObject(hPen1);
DeleteObject(hPen2);
DeleteObject(OldBM);
DeleteObject(MemBM);
DeleteObject(GdiObj);
}
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow)
{
WNDCLASS Wc;
MSG Msg;
Wc.style=CS_HREDRAW BOR CS_VREDRAW BOR CS_DBLCLKS;
Wc.lpfnWndProc=WndProc;
Wc.cbClsExtra=0;
Wc.cbWndExtra=0;
Wc.hInstance=hInst;
Wc.hIcon=LoadIcon(NULL,IDI_WINLOGO);
Wc.hCursor=LoadCursor(NULL,IDC_ARROW);
Wc.hbrBackground=GetSysColorBrush(COLOR_BTNFACE);
Wc.lpszMenuName=NULL;
Wc.lpszClassName=ClassName1;
RegisterClass( &Wc);
FormLoad(hInst);
while(GetMessage( &Msg,NULL,0,0))
{
if(!IsWindow(GetActiveWindow())||!IsDialogMessage(GetActiveWindow(), &Msg))
{
TranslateMessage( &Msg);
DispatchMessage( &Msg);
}
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
for(;
{
if(Msg==WM_TIMER)
{
UpdateGraph(Rect1,rnd()*50,50);
DrawGraph(Rect1);
UpdateGraph(Rect2,rnd()*50,50);
DrawGraph(Rect2);
return 0;
}
if(Msg==WM_COMMAND)
{
if(LOWORD(wParam)==ID_PUSH)
{
if(OurTimer==0)
{
OurTimer=SetTimer(Form1,1,33,0);
SetWindowText(Button1,"Stop All");
EnableWindow(Button2,TRUE);
EnableWindow(Button3,TRUE);
if(OurTimer==0)
{
MessageBox(Form1,"Cannot Create Timer","Error",MB_OK);
PostQuitMessage(0);
}
}
else
{
KillTimer(Form1,OurTimer);
OurTimer=0;
SetWindowText(Button1,"Start All");
EnableWindow(Button2,FALSE);
EnableWindow(Button3,FALSE);
}
}
else if(LOWORD(wParam)==ID_FREEZE1)
{
if(IsGraphFrozen(Rect1)==FALSE)
{
FreezeGraph(Rect1,1);
SetWindowText(Button2,"Thaw Graph1");
}
else
{
FreezeGraph(Rect1,0);
SetWindowText(Button2,"Freeze Graph1");
}
}
else if(LOWORD(wParam)==ID_FREEZE2)
{
if(IsGraphFrozen(Rect2)==FALSE)
{
FreezeGraph(Rect2,1);
SetWindowText(Button3,"Thaw Graph2");
}
else
{
FreezeGraph(Rect2,0);
SetWindowText(Button3,"Freeze Graph2");
}
}
return 0;
}
if(Msg==WM_CLOSE)
{
static int id;
memset(&id,0,sizeof(id));
id=MessageBox(hWnd,"Are you sure?","Quit Program!",MB_YESNO);
if(id==IDYES)
{
DestroyWindow(hWnd);
}
return 0;
}
if(Msg==WM_DESTROY)
{
CloseGraph(Rect1);
CloseGraph(Rect2);
PostQuitMessage(0);
return 0;
}
if(Msg==WM_PAINT)
{
DrawGraph(Rect1);
DrawGraph(Rect2);
}
break;
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
void FormLoad (HINSTANCE hInst)
{
BCX_GetDiaUnit=GetDialogBaseUnits();
BCX_cxBaseUnit=LOWORD(BCX_GetDiaUnit);
BCX_cyBaseUnit=HIWORD(BCX_GetDiaUnit);
BCX_ScaleX=BCX_cxBaseUnit/4;
BCX_ScaleY=BCX_cyBaseUnit/8;
Form1=CreateWindow(ClassName1,CaptionName1,DS_MODALFRAME BOR WS_POPUP BOR WS_CAPTION BOR WS_SYSMENU,0,0,195*BCX_ScaleX,90*BCX_ScaleY,NULL,(HMENU)NULL,hInst,NULL);
Rect1=CreateWindowEx(0,"static","",WS_CHILD BOR SS_NOTIFY BOR WS_VISIBLE BOR SS_BLACKRECT BOR SS_OWNERDRAW,5,10,90*BCX_ScaleX,50*BCX_ScaleY,Form1,(HMENU)ID_GRAPH1,hInst,NULL);
Rect2=CreateWindowEx(0,"static","",WS_CHILD BOR SS_NOTIFY BOR WS_VISIBLE BOR SS_BLACKRECT BOR SS_OWNERDRAW,100*BCX_ScaleX,10,90*BCX_ScaleX,50*BCX_ScaleY,Form1,(HMENU)ID_GRAPH2,hInst,NULL);
InitGraph(Rect1,RGB(0,0,255),RGB(0,100,0),3,GRAPH_LEFT);
InitGraph(Rect2,RGB(255,0,0),RGB(0,100,0),7,GRAPH_RIGHT);
Button1=CreateWindowEx(0,"button","Start All",WS_CHILD BOR WS_TABSTOP BOR BS_PUSHBUTTON BOR WS_VISIBLE,75*BCX_ScaleX,60*BCX_ScaleY,40*BCX_ScaleX,14*BCX_ScaleY,Form1,(HMENU)ID_Button1,hInst,NULL);
SendMessage(Button1,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0));
Button2=CreateWindowEx(0,"button","Freeze Graph1",WS_CHILD BOR WS_TABSTOP BOR BS_PUSHBUTTON BOR WS_VISIBLE,25*BCX_ScaleX,60*BCX_ScaleY,50*BCX_ScaleX,14*BCX_ScaleY,Form1,(HMENU)ID_FREEZE1,hInst,NULL);
SendMessage(Button2,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0));
Button3=CreateWindowEx(0,"button","Freeze Graph2",WS_CHILD BOR WS_TABSTOP BOR BS_PUSHBUTTON BOR WS_VISIBLE,125*BCX_ScaleX,60*BCX_ScaleY,50*BCX_ScaleX,14*BCX_ScaleY,Form1,(HMENU)ID_FREEZE2,hInst,NULL);
SendMessage(Button3,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0));
EnableWindow(Button2,FALSE);
EnableWindow(Button3,FALSE);
Center(Form1);
Show(Form1);
}