E
Eric Lilja
This complete program compiles just fine:
void foo(int, int = 0);
void foo(int a, int b)
{
(void)a;
(void)b;
}
int
main()
{
foo4711);
}
However, this part of the *real* program does not:
void register_window_class(const char *class_name,
WNDPROC proc,
HBRUSH background,
const char * = NULL,
HICON = LoadIcon(0, IDI_APPLICATION),
HCURSOR = LoadCursor(0, IDC_ARROW),
UINT = CS_HREDRAW | CS_VREDRAW,
int = 0,
int = 0);
void register_class(const char *class_name,
WNDPROC proc,
HBRUSH background,
const char *menu_name,
HICON icon,
HCURSOR cursor,
UINT style,
int cbWndExtra,
int cbClsExtra)
{
WNDCLASS wndclass;
ZeroMemory(&wndclass, sizeof(WNDCLASS));
wndclass.style = style; /* Usually CS_HREDRAW | CS_VREDRAW */
wndclass.lpfnWndProc = proc;
wndclass.cbClsExtra = cbClsExtra; /* Usually 0 */
wndclass.cbWndExtra = cbWndExtra; /* Usually 0 */
wndclass.hInstance = NULL;
wndclass.hIcon = icon; /* Usually LoadIcon(0, IDI_APPLICATION) */
wndclass.hCursor = cursor; /* Usually LoadCursor(0, IDC_ARROW) */
wndclass.hbrBackground = background; /*
(HBRUSH)GetStockObject(WHITE_BRUSH) */
wndclass.lpszMenuName = menu_name; /* NULL or
MAKEINTRESOURCE(MENU_ID) */
wndclass.lpszClassName = class_name;
ATOM a = RegisterClass(&wndclass);
assert(a != 0);
}
HWND
MainWindow::create()
{
const char *application_name = "Test MyMFC"; /* Doubling as class
name. */
register_class(application_name, MainWindow::entry,
(HBRUSH)GetStockObject(WHITE_BRUSH));
g++ -Wall -W -ansi -pedantic -g -O0 -c MainWindow.cpp
MainWindow.cpp: In member function `HWND__* MainWindow::create()':
MainWindow.cpp:22: error: too few arguments to function `void
register_class(const char*, LRESULT (*)(HWND__*, UINT, WPARAM, LPARAM),
HBRUSH__*, const char*, HICON__*, HICON__*, UINT, int, int)'
MainWindow.cpp:48: error: at this point in file
Line 48 is the call to register_class...how do I make it compile while
keeping my default arguments? Sorry for posting an incomplete snippet
filled to the brim with platform specific code, but what was supposed
to be my exhibition program failed to exhibit the problem I need help
solving. =/
/ E
void foo(int, int = 0);
void foo(int a, int b)
{
(void)a;
(void)b;
}
int
main()
{
foo4711);
}
However, this part of the *real* program does not:
void register_window_class(const char *class_name,
WNDPROC proc,
HBRUSH background,
const char * = NULL,
HICON = LoadIcon(0, IDI_APPLICATION),
HCURSOR = LoadCursor(0, IDC_ARROW),
UINT = CS_HREDRAW | CS_VREDRAW,
int = 0,
int = 0);
void register_class(const char *class_name,
WNDPROC proc,
HBRUSH background,
const char *menu_name,
HICON icon,
HCURSOR cursor,
UINT style,
int cbWndExtra,
int cbClsExtra)
{
WNDCLASS wndclass;
ZeroMemory(&wndclass, sizeof(WNDCLASS));
wndclass.style = style; /* Usually CS_HREDRAW | CS_VREDRAW */
wndclass.lpfnWndProc = proc;
wndclass.cbClsExtra = cbClsExtra; /* Usually 0 */
wndclass.cbWndExtra = cbWndExtra; /* Usually 0 */
wndclass.hInstance = NULL;
wndclass.hIcon = icon; /* Usually LoadIcon(0, IDI_APPLICATION) */
wndclass.hCursor = cursor; /* Usually LoadCursor(0, IDC_ARROW) */
wndclass.hbrBackground = background; /*
(HBRUSH)GetStockObject(WHITE_BRUSH) */
wndclass.lpszMenuName = menu_name; /* NULL or
MAKEINTRESOURCE(MENU_ID) */
wndclass.lpszClassName = class_name;
ATOM a = RegisterClass(&wndclass);
assert(a != 0);
}
HWND
MainWindow::create()
{
const char *application_name = "Test MyMFC"; /* Doubling as class
name. */
register_class(application_name, MainWindow::entry,
(HBRUSH)GetStockObject(WHITE_BRUSH));
g++ -Wall -W -ansi -pedantic -g -O0 -c MainWindow.cpp
MainWindow.cpp: In member function `HWND__* MainWindow::create()':
MainWindow.cpp:22: error: too few arguments to function `void
register_class(const char*, LRESULT (*)(HWND__*, UINT, WPARAM, LPARAM),
HBRUSH__*, const char*, HICON__*, HICON__*, UINT, int, int)'
MainWindow.cpp:48: error: at this point in file
Line 48 is the call to register_class...how do I make it compile while
keeping my default arguments? Sorry for posting an incomplete snippet
filled to the brim with platform specific code, but what was supposed
to be my exhibition program failed to exhibit the problem I need help
solving. =/
/ E