Italian community of Lazarus and Free Pascal

Programmazione => Generale => Topic aperto da: xinyiman - Settembre 07, 2014, 05:36:02 pm

Titolo: Da C al Pascal
Inserito da: xinyiman - Settembre 07, 2014, 05:36:02 pm
Chi mi aiuta a convertire questo?!

Codice: [Seleziona]
/*
 * Configuration
 */

#ifndef CONFIG_H
#define CONFIG_H

/* Default memory device file */
#if defined(__BEOS__) || defined(__HAIKU__)
#define DEFAULT_MEM_DEV "/dev/misc/mem"
#else
#ifdef __sun
#define DEFAULT_MEM_DEV "/dev/xsvc"
#else
#define DEFAULT_MEM_DEV "/dev/mem"
#endif
#endif

/* Use mmap or not */
#ifndef __BEOS__
#define USE_MMAP
#endif

/* Use memory alignment workaround or not */
#ifdef __ia64__
#define ALIGNMENT_WORKAROUND
#endif

#endif
Titolo: Re:Da C al Pascal
Inserito da: Legolas - Settembre 07, 2014, 09:55:19 pm
Vado a memoria, qualcosa del tipo:

Codice: [Seleziona]
const
  DEFAULT_MEM_DEV = '';
 
(* Default memory device file *)
{$if defined(__BEOS__) or defined(__HAIKU__)}
  DEFAULT_MEM_DEV = '/dev/misc/mem';
{$else}
  {$ifdef __sun}
    DEFAULT_MEM_DEV = '/dev/xsvc';
  {$else}
    DEFAULT_MEM_DEV = '/dev/mem';
  {$endif}
{$endif}

(* Use mmap or not *)
{$ifndef __BEOS__}
  {$define USE_MMAP}
{$endif}

(* Use memory alignment workaround or not *)
{$ifdef __ia64__}
  {$define ALIGNMENT_WORKAROUND}
{$endif}

Potresti anche utilizzare le macro per definire DEFAULT_MEM_DEV come simbolo invece che come costante

Codice: [Seleziona]
{$MACRO ON} 

(* Default memory device file *)
{$if defined(__BEOS__) or defined(__HAIKU__)}
  {$define DEFAULT_MEM_DEV := '/dev/misc/mem'}
{$else}
...

 ma credo che una const dovrebbe bastare