From: Robby on
Hello,

Sorry for the abundance of questions that I am posting !

I don't understand why the program is still able to see a function prototype
(called API_CreateWindow()) declared in a header when I am not including that
header in the .c file which has the calling function of API_CreateWindow(). I
am supposed to get an error but I don't. I was getting ready to post a
different question when I was faced with this problem... so excuse me if my
sample is longer than it should be.

The problem strikes me at lines 45 and 59 and 75.

Please view the following sample code:

==========================KERNEL.h (L1)
#ifndef KERNEL_H
#define KERNEL_H

typedef long *LRESULT;
typedef long WPARAM;
typedef long LPARAM;

typedef struct tagHwnd {
long caption_msg;
} HWND;

typedef struct tagMsg {
HWND hwnd;
long msg;
WPARAM wParam;
LPARAM lParam;
long time;
} KM_MSG;

typedef LRESULT(*callBack)(HWND hwnd, long message, WPARAM w, LPARAM l);
#endif // KERNEL_H //

==========================KERNEL.c (L24)
#include <stdio.h>
#include "KERNEL.h"
#include "WP_INTRO.h"
#include "MAIN.h"
callBack cb[1];

int main(void)
{
KM_MSG m; HWND hwnd;
hwnd.caption_msg = 1; m.msg = 1; m.lParam = 2; m.wParam = 3;
cb[0] = CALLBACK_WP_INTRO;
f1();
CALLBACK_WP_INTRO(hwnd, m.msg, m.wParam, m.lParam);
}

==========================MAIN.h (L40)
#ifndef MAIN_H
#define MAIN_H

#include "KERNEL.h"
//#include "API.h" // <<< here! API.h not included!!!! But MAIN.c is
still sees
// API_CreateWindow () function ????
#include "WP_INTRO.h"

void f1(void);

#endif // MAIN_H //
==========================MAIN.c L(52)
#include "MAIN.h"
callBack cb[6];

void f1(void)
{int y = 0;

HWND API_CreateWindow // <<< Calling function!

(
int WND_ID,
long caption_msg,
int i_x_pos,
int i_x_size,
int i_y_pos,
int i_y_size);
}

==========================API.h (L69)
#ifndef API_H
#define API_H

#include "KERNEL.h"

// Function Declaration never included in MAIN.h ???
HWND API_CreateWindow
(
int WND_ID,
long caption_msg,
int i_x_pos,
int i_x_size,
int i_y_pos,
int i_y_size);

#endif // API_H //

==========================API.c (L76)
#include "API.h"

HWND API_CreateWindow
(
int WND_ID,
long caption_msg,
int i_x_pos,
int i_x_size,
int i_y_pos,
int i_y_size)
{int i; HWND h;
//......other code
return h; }

==========================WP_INTRO.h (L91)
#ifndef WP_INTRO_H
#define WP_INTRO_H

#include "KERNEL.h"

LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam);

#endif // WP_INTRO_H //

==========================WP_INTRO.c (L101)
#include "WP_INTRO.h"

LRESULT CALLBACK_WP_INTRO(HWND hwnd, long message, WPARAM wParam, LPARAM
lParam)
{
return 0;
}

================================== (L110)

In summary, doesn't MAIN.h have to include API.h so to include the following
function declaration:

=================================API.h
HWND API_CreateWindow
(
int WND_ID,
long caption_msg,
int i_x_pos,
int i_x_size,
int i_y_pos,
int i_y_size);
=========================

so that MAIN.c can call it ?

--
Best regards
Roberto
From: Robby on
I SINCERELY APOLOGIZE FOR THE MULTIPLE POSTS!

AS I POSTED MY 1ST POST, I DID NOT SEE THE MESSAGE/SUBJECT TITLE APPEAR IN
THE LIST AS IT USUALLY DOES. SO I POSTED A SECOND TIME AND STILL NOTHING.

SO I THOUGHT IT WAS BECAUSE I USED AN "=" CHARACTER IN MY SUBJECT LINE, SO I
POSTED AGAIN WITHOUT THE "=" CHARACTER IN THE SUBJECT.

STILL MY POST WOULD NOT APPEAR AND I SUDDENLY SAW AN OUT OF SERVICE MESSAGE.

AGAIN, SORRY FOR THE MULTIPLE POSTS!!!

ROBERT