Sign in Join

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

Mailing lists / fpc-pascal / 2005-07

Single or Double

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Marcel Martin

Hello,

I need to know *at compile time* whether the type Real is Single or Double. Currently, I use this

{$IFDEF FPC_HAS_TYPE_DOUBLE}
  ...
{$ELSE}
{$IFDEF FPC_HAS_TYPE_SINGLE}
  ...
{$ELSE}
   {$FATAL Type Real should be defined as Single or as Double}
{$ENDIF} // FPC_HAS_TYPE_SINGLE
{$ENDIF} // FPC_HAS_TYPE_DOUBLE

This works. But is it a reliable way of doing? Since the FPC_HAS_TYPE_XXX directives are not documented, I have a little doubt ;-)
Thanks.

mm

Reply by email

Florian Klaempfl
to Marcel Martin
Marcel Martin wrote 18 lines
Hello, I need to know *at compile time* whether the type Real is Single or Double. Currently, I use this {$IFDEF FPC_HAS_TYPE_DOUBLE} ... {$ELSE} {$IFDEF FPC_HAS_TYPE_SINGLE} ... {$ELSE} {$FATAL Type Real should be defined as Single or as Double} {$ENDIF} // FPC_HAS_TYPE_SINGLE {$ENDIF} // FPC_HAS_TYPE_DOUBLE This works. But is it a reliable way of doing? Since the FPC_HAS_TYPE_XXX directives are not documented, I have a little doubt ;-)

They won't be removed, they are too new to be documented :)

Reply by email

Marcel Martin
to Florian Klaempfl
Florian Klaempfl wrote 23 lines
Marcel Martin wrote: >Hello, > >I need to know *at compile time* whether the type Real is >Single or Double. Currently, I use this > >{$IFDEF FPC_HAS_TYPE_DOUBLE} > ... >{$ELSE} >{$IFDEF FPC_HAS_TYPE_SINGLE} > ... >{$ELSE} > {$FATAL Type Real should be defined as Single or as Double} >{$ENDIF} // FPC_HAS_TYPE_SINGLE >{$ENDIF} // FPC_HAS_TYPE_DOUBLE > >This works. But is it a reliable way of doing? Since the >FPC_HAS_TYPE_XXX directives are not documented, I have a >little doubt ;-) They won't be removed, they are too new to be documented :)

Thanks. I keep it as it is.

mm

Reply by email

Rimgaudas Laucius
to Marcel Martin

Hello,

the problem is that IDEs like FP and others have no exact place where to store compiler configuration switches and other program (project) related info. For examle if user set switches in FP, they effect all opened units, so there is no possibility to configure each unit differently if you do not use directives. That is problem for less experienced users, like students. I want to propose an idea of implementation alternative source format able to carry all additional information. This can be open format realized using xml. It will not make problems with conversion to native "pas" format. Additional argument that FPC will support UTF-8 soon.

Something like this:

<?xml version="1.0" encoding="UTF-8"?>
<fpc>
<version>1.0</version>
<switches target="debug">-viewh -g -Cotir -Sd</switches> <switches target="release">-viewh -O2 -Sd</switches> <todo>There is nothing to do</todo>
<target>win32</target>
...
<body>
begin

  writeln('hi');
  readln;

end.
</body>
</fpc>

What do you think about this?

Regards,
Rimgaudas

Reply by email

Michael Van Canneyt
to Rimgaudas Laucius
Rimgaudas Laucius wrote 33 lines
Hello, the problem is that IDEs like FP and others have no exact place where to store compiler configuration switches and other program (project) related info. For examle if user set switches in FP, they effect all opened units, so there is no possibility to configure each unit differently if you do not use directives. That is problem for less experienced users, like students. I want to propose an idea of implementation alternative source format able to carry all additional information. This can be open format realized using xml. It will not make problems with conversion to native "pas" format. Additional argument that FPC will support UTF-8 soon. Something like this: <?xml version="1.0" encoding="UTF-8"?> <fpc> <version>1.0</version> <switches target="debug">-viewh -g -Cotir -Sd</switches> <switches target="release">-viewh -O2 -Sd</switches> <todo>There is nothing to do</todo> <target>win32</target> ... <body> begin writeln('hi'); readln; end. </body> </fpc> What do you think about this?

This is something for an IDE, not for the compiler itself. An IDE is free to store it's sources as it wants.

Parsing XML adds a lot of processing overhead, so should not be supported in the compiler. What is more, most relevant command-line options can be specified with directives, so you don't really need the 'extra' info in the compiler sources.

But if you want to add such an extension to the IDE, please do.

Michael.

Reply by email

Marc Santhoff
to Rimgaudas Laucius: the problem is that IDEs like FP and others have no exact place where to store compiler…
Rimgaudas Laucius wrote
Hello,

Hi,

Show quoted text 6 lines
the problem is that IDEs like FP and others have no exact place where to store compiler configuration switches and other program (project) related info. For examle if user set switches in FP, they effect all opened units, so there is no possibility to configure each unit differently if you do not use directives.

Since my IDE is JEdit I'm not sure, but each IDE for pascal I used in the past had a key combination for inserting the compiler switches in the code. Wasn't it CTRL-I-I in Delphi?

Show quoted text 14 lines
That is problem for less experienced users, like students. I want to propose an idea of implementation alternative source format able to carry all additional information. This can be open format realized using xml. It will not make problems with conversion to native "pas" format. Additional argument that FPC will support UTF-8 soon. Something like this: <?xml version="1.0" encoding="UTF-8"?> [...] </fpc> What do you think about this?

If you're a teacher or the like and want to have full documentation in your source files you might wan't to consider literate programming. There are many tools out there, one of them I personally like for writing documentation centric code is funnelweb. This way you can produce nice documentation containing the well formatted code and anything belonging to one source project and on the other hand you can produce nicely formatted source code and even a makefile for compiling.

I don't like the idea of having XML files as a basis. But If you do, how about writing en extension to the IDE or Lazarus and the necessary converters as a teaching project?

Marc

Reply by email

Rimgaudas Laucius
to Marc Santhoff

Hello,

i had in mind something like unified project format for all pascal's IDEs. Open XML formats are popular in open source world now. But i do not think this idea were anymore.

Show quoted text 49 lines
> Hello, Hi, > the problem is that IDEs like FP and others have no exact > place where to store compiler configuration switches and > other program (project) related info. For examle if user set > switches in FP, they effect all opened units, so there is no > possibility to configure each unit differently if you do not use > directives. Since my IDE is JEdit I'm not sure, but each IDE for pascal I used in the past had a key combination for inserting the compiler switches in the code. Wasn't it CTRL-I-I in Delphi? > That is problem for less experienced users, like students. > I want to propose an idea of implementation alternative > source format able to carry all additional information. > This can be open format realized using xml. It will not make problems > with conversion to native "pas" format. Additional argument that FPC > will support UTF-8 soon. > > Something like this: > > <?xml version="1.0" encoding="UTF-8"?> > [...] > </fpc> > > What do you think about this? If you're a teacher or the like and want to have full documentation in your source files you might wan't to consider literate programming. There are many tools out there, one of them I personally like for writing documentation centric code is funnelweb. This way you can produce nice documentation containing the well formatted code and anything belonging to one source project and on the other hand you can produce nicely formatted source code and even a makefile for compiling. I don't like the idea of having XML files as a basis. But If you do, how about writing en extension to the IDE or Lazarus and the necessary converters as a teaching project? Marc _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

L505
to Rimgaudas Laucius

| i had in mind something like unified project format for all pascal's IDEs. | Open XML formats are popular in open source world now. But i do not think

I think Pascal code and basic config files are a lot easier to read than XML and all the tags. I think XML obfuscates the pascal code. With something like FPDOC, XML can work well because there are very sparse tags (more text than tags).. so it doesn't obfuscate the document.

Reply by email