Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-09

FPC and ANSI C

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Valdas Jankūnas

Hello,

is there way to share constants between FPC and ANSI C?

I writing firmware for device (with Atmel 8bit) using ANSI C, also I writing software for PC (to communicate with that device) using Free Pascal. Both firmware and software using some same numeric constants (used in communication protocol), for example in firmware: #define SEND_DATA 1
in software:

    const SEND_DATA = 1;
  My problem is that I always must synchronise values in both sources.
  So, I want that C compiler will read constants from FPC source, or FPC

compiler read from C source, or both compilers reads from some custom file. Is this possible? How implement this?

Thanks for suggestions.

Valdas Jankūnas

Reply by email

Jonas Maebe
to Valdas Jankūnas
Valdas Jankūnas wrote 6 lines
I writing firmware for device (with Atmel 8bit) using ANSI C, also I writing software for PC (to communicate with that device) using Free Pascal. Both firmware and software using some same numeric constants (used in communication protocol), for example in firmware: #define SEND_DATA 1 in software: const SEND_DATA = 1; My problem is that I always must synchronise values in both sources. So, I want that C compiler will read constants from FPC source, or FPC compiler read from C source, or both compilers reads from some custom file. Is this possible? How implement this?

The easiest way is probably to create a C include file that contains all constants as defines, and then automatically generating the Pascal version of the include with "h2pas -i cinclude.h -o pinclude.inc".

Jonas

Reply by email

Valdas Jankūnas
to Jonas Maebe
Jonas Maebe wrote
> My problem is that I always must synchronise values in both sources. > So, I want that C compiler will read constants from FPC source, or FPC compiler read from C source, or both compilers reads from some custom file. Is this possible? How implement this? The easiest way is probably to create a C include file that contains all constants as defines, and then automatically generating the Pascal version of the include with "h2pas -i cinclude.h -o pinclude.inc".

Thanks, his will make my life easier :)

Valdas Jankūnas

Reply by email