Board index » delphi » How to declare external typedef struct

How to declare external typedef struct

There are two separated c and h files, which are stutter.c, stutter.h,
ClipExt.c and ClipExt.h.  The typedef struct and enum is listed at the
end of this text

The ClipCtrlType ClipCtrl[ PSTN_LINES ]; is defined in ClipExt.c and
the extern ClipCtrlType ClipCtrl[ PSTN_LINES ]; is defined in ClipExt.h

If I want to put the ClipCtrl[ ClipLineId ].Flags.DtasDetectActive = 0; in
stutter.c,
Firstly, I have to declare that ClipCtrl is defined in somewhere else.

So I put extern ClipCtrlType ClipCtrlp[PSTN_LINES] in stutter.h but the
compiler prompts me with the error
"Invalid declaration on syntax, unexpected identifier"
(remark: PSTN_LINES is Global defined)
The compiler doesn't know the typedef struct of ClipCtrlType.

However, if I put #include <ClipExt.h> in stutter.c, it prompts me with the
error "S_INIT, S_RINGING... redefined".

So, is there any simple method to declare self defined type just like
declare "extern int test" telling the compiler that the variable test is
defined in somewhere else?

In stutter.c, it has the typedef enum like this
typedef enum
{
  S_INIT,
  S_IDLE,
  S_IDLE_WAIT,
  S_RINGING,
  S_SYNC,
  S_DETECT,
  S_INUSE,
  S_INUSE_END,

  S_NUMBER_OF_STUTTER_STATES,
  S_UNDEFINED_STATE

Quote
} ENUM8(StutterStateType);

In ClipExt.h, it has the typedef struct like this

typedef enum
{
  S_INIT,

  S_IDLE_ONHOOK,
  S_IDLE_OFFHOOK,

  S_RINGING,
  S_RPAS,
  S_RPAS_MAX,

  S_DTAS,
  S_CAS,
  S_DTMF,

  S_FSK_MSG,
  S_FSK_MARKOUT,

  S_NUMBER_OF_CLIP_STATES,
  S_UNDEFINED_STATE

Quote
} ENUM8(ClipStateType);

.......

typedef struct
{
  ClipStateType     State;
  ClipCtrlFlagType  Flags;
  Time1msType       TimeRingStart;
  Time1msType       TimeStampOn;
  Time1msType       TimeStampOff;

Quote
} ClipCtrlType;

 

Re:How to declare external typedef struct


Hi,

for the maintenance of some older applications I must still use Borlanc
C/C++ 4.52 with the add-on PowerPack 1.0, it's the last compiler version
which supported the DOS extender.

I had no problem running this under Win 9.x or win Nt 4.x, but I won't
get it working with win 2000 or win XP.

Creating a dir "windows" with subdirs system and system32, setting a
path to those dirs, BC 4.52 is working, but never accepts the power pack
add-on.

Does anyone know how to solve this problem ?

Wolfgang Spitzbarth, ThermoRadiometrie

Re:How to declare external typedef struct


Quote
"Billy Tsang" <billy_ts...@ctimail3.com> writes:
> There are two separated c and h files, which are stutter.c, stutter.h,
> ClipExt.c and ClipExt.h.  The typedef struct and enum is listed at the
> end of this text

Could you please reduce your code (e.g. reduce the number of enumerators), and
post very clearly what you declare/define in what file so that your audience
can easily copy&paste&reproduce. Thanks.

BTW: What's ENUM8?

Re:How to declare external typedef struct


"Thomas Maeder" <mae...@glue.ch> ???????:m3lm91lonz....@madbox.local...

Quote
> "Billy Tsang" <billy_ts...@ctimail3.com> writes:

> > There are two separated c and h files, which are stutter.c, stutter.h,
> > ClipExt.c and ClipExt.h.  The typedef struct and enum is listed at the
> > end of this text

> Could you please reduce your code (e.g. reduce the number of enumerators),
and
> post very clearly what you declare/define in what file so that your
audience
> can easily copy&paste&reproduce. Thanks.

> BTW: What's ENUM8?

The code is reduce list at the end.

The ClipCtrlType ClipCtrl; is defined in ClipExt.c and
the extern ClipCtrlType ClipCtrl; is defined in ClipExt.h

If I want to set the ClipCtrl.Flags.test = 0; inside
stutter.c file, I have to declare it is defined in external.

However, if I put #include <ClipExt.h> in stutter.c
The compiler have the following error "S_INIT redefined".

If I put extern ClipCtrlType ClipCtrl in stutter.h just like
declare "extern int test" to tell the compiler that the variable test is
defined in somewhere else.
The compiler have the following error "Invalid declaration on syntax,
unexpected identifier"

So, is there any simple method to declare external self-defined type?

In stutter.c, it has the typedef enum like this
typedef enum
{
  S_INIT,
  S_TEST

Quote
} StutterStateType;

In ClipExt.h, it has the typedef struct like this

typedef enum
{
  S_INIT,
  S_ABC

Quote
} ClipStateType;

.......

typedef struct
{
  ClipStateType       State;
  ClipCtrlFlagType  Flags;

Quote
} ClipCtrlType;

Re:How to declare external typedef struct


Hi,

for the maintenance of some older applications I must still use Borlanc
C/C++ 4.52 with the add-on PowerPack 1.0, it's the last compiler version
which supported the DOS extender.

I had no problem running this under Win 9.x or win Nt 4.x, but I won't
get it working with win 2000 or win XP.

Creating a dir "windows" with subdirs system and system32, setting a
path to those dirs, BC 4.52 is working, but never accepts the power pack
add-on.

Does anyone know how to solve this problem ?

Wolfgang Spitzbarth, ThermoRadiometrie

Re:How to declare external typedef struct


On Thu, 27 Jun 2002 08:24:30 +0200, Wolfgang Spitzbarth
Quote
<wolfgang.spitzba...@radiometrie.com> wrote:

I am using successful BC452 and PowerPack under Win2000 and XP.
You have to put the BCW.INI file to winnt folder.
But the installation is working well for me.  

Quote
>Hi,

>for the maintenance of some older applications I must still use Borlanc
>C/C++ 4.52 with the add-on PowerPack 1.0, it's the last compiler version
>which supported the DOS extender.

>I had no problem running this under Win 9.x or win Nt 4.x, but I won't
>get it working with win 2000 or win XP.

>Creating a dir "windows" with subdirs system and system32, setting a
>path to those dirs, BC 4.52 is working, but never accepts the power pack
>add-on.

>Does anyone know how to solve this problem ?

>Wolfgang Spitzbarth, ThermoRadiometrie

With best regards
  Vladimir E. Zhuchko

Re:How to declare external typedef struct


Quote
"Billy Tsang" <billy_ts...@ctimail3.com> writes:
> > and post very clearly what you declare/define in what file so that your
> > audience can easily copy&paste&reproduce.

Still not clear enough (for me).

Quote
> The ClipCtrlType ClipCtrl; is defined in ClipExt.c and
> the extern ClipCtrlType ClipCtrl; is defined in ClipExt.h

The following shows what would be clear enough:

// file ClipExt.h

#if !defined(CLIPEXT_H)
#define CLIPEXT_H

extern ClipCtrlType ClipCtrl;

#endif

// file ClipExt.c

ClipCtrlType ClipCtrl;

etc.

Re:How to declare external typedef struct


"Thomas Maeder" <mae...@glue.ch> ???????:m3lm91lonz....@madbox.local...

Quote
> "Billy Tsang" <billy_ts...@ctimail3.com> writes:

> > There are two separated c and h files, which are stutter.c, stutter.h,
> > ClipExt.c and ClipExt.h.  The typedef struct and enum is listed at the
> > end of this text

> Could you please reduce your code (e.g. reduce the number of enumerators),
and
> post very clearly what you declare/define in what file so that your
audience
> can easily copy&paste&reproduce. Thanks.

> BTW: What's ENUM8?

The code is reduce list at the end.

The ClipCtrlType ClipCtrl; is defined in ClipExt.c and
the extern ClipCtrlType ClipCtrl; is defined in ClipExt.h

If I want to set the ClipCtrl.Flags.test = 0; inside
stutter.c file, I have to declare it is defined in external.

However, if I put #include <ClipExt.h> in stutter.c
The compiler have the following error "S_INIT redefined".

If I put extern ClipCtrlType ClipCtrl in stutter.h just like
declare "extern int test" to tell the compiler that the variable test is
defined in somewhere else.
The compiler have the following error "Invalid declaration on syntax,
unexpected identifier"

So, is there any simple method to declare external self-defined type?

In stutter.c, it has the typedef enum like this
typedef enum
{
  S_INIT,
  S_TEST

Quote
} StutterStateType;

In ClipExt.h, it has the typedef struct like this

typedef enum
{
  S_INIT,
  S_ABC

Quote
} ClipStateType;

.......

typedef struct
{
  ClipStateType       State;
  ClipCtrlFlagType  Flags;

Quote
} ClipCtrlType;

Re:How to declare external typedef struct


Hi,

for the maintenance of some older applications I must still use Borlanc
C/C++ 4.52 with the add-on PowerPack 1.0, it's the last compiler version
which supported the DOS extender.

I had no problem running this under Win 9.x or win Nt 4.x, but I won't
get it working with win 2000 or win XP.

Creating a dir "windows" with subdirs system and system32, setting a
path to those dirs, BC 4.52 is working, but never accepts the power pack
add-on.

Does anyone know how to solve this problem ?

Wolfgang Spitzbarth, ThermoRadiometrie

Re:How to declare external typedef struct


On Thu, 27 Jun 2002 08:24:30 +0200, Wolfgang Spitzbarth
Quote
<wolfgang.spitzba...@radiometrie.com> wrote:

I am using successful BC452 and PowerPack under Win2000 and XP.
You have to put the BCW.INI file to winnt folder.
But the installation is working well for me.  

Quote
>Hi,

>for the maintenance of some older applications I must still use Borlanc
>C/C++ 4.52 with the add-on PowerPack 1.0, it's the last compiler version
>which supported the DOS extender.

>I had no problem running this under Win 9.x or win Nt 4.x, but I won't
>get it working with win 2000 or win XP.

>Creating a dir "windows" with subdirs system and system32, setting a
>path to those dirs, BC 4.52 is working, but never accepts the power pack
>add-on.

>Does anyone know how to solve this problem ?

>Wolfgang Spitzbarth, ThermoRadiometrie

With best regards
  Vladimir E. Zhuchko

Re:How to declare external typedef struct


Quote
"Billy Tsang" <billy_ts...@ctimail3.com> writes:
> > and post very clearly what you declare/define in what file so that your
> > audience can easily copy&paste&reproduce.

Still not clear enough (for me).

Quote
> The ClipCtrlType ClipCtrl; is defined in ClipExt.c and
> the extern ClipCtrlType ClipCtrl; is defined in ClipExt.h

The following shows what would be clear enough:

// file ClipExt.h

#if !defined(CLIPEXT_H)
#define CLIPEXT_H

extern ClipCtrlType ClipCtrl;

#endif

// file ClipExt.c

ClipCtrlType ClipCtrl;

etc.

Other Threads