cctsao1008 / picoc

Automatically exported from code.google.com/p/picoc
0 stars 0 forks source link

Doesn't compile under VC.net #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
All right, I got the code from the CVS repository (as of today, around 9h00
local Montreal time).

I rebuilt the Win32 projects using your code and I mostly discarded mine --
the only think I kept for now is the api.c file which exposes the API
through the PicoC DLL.

I had to make a few changes to make things compile on .NET 2008, and I also
have a couple of observations:
clibrarry.c:
    - LibraryInit: I don't know why you don't simply use a struct
LibraryFunction pointer instead of the convoluted array declaration. It
makes it impossible to compile a call to
      LibraryInit unless the full definition of the array is known,
something which won't happen through an API. Making it a pointer removes
nothing and even makes the code clearer.
    - LibraryInit: you hard-code the library name to "c library" instead of
using the name provided on input.
    - CLibraryInit(): this is where the call to LibraryInit() should be
made for the CLibrary. It makes more sense than asking the global
initialization code to perform both CLibraryInit() and LibraryInit() for
the C library.
    - PrintFP(): 
        - some casts are required: when assigning a value to Exponent
        - you should call math_fabs() instead of abs() to work with Num --
the function is there and is platform-ized
    - LibSPrintf(): I get an uninitialized variable warning on
StrStream.i.Str.Parser. I initialized it with the struct Parser pointer on
input, but I don't know if that's the right thing to do.
    - LibAsynh, LibAcosh, LibAtanh: the functions are not defined on
Windows -- I had to #ifdef them out. For me that's not a big deal.
- expression.c:
    - Some casts are required. .NET is pricky about comparisons between
ints and non-ints. I converted to unsigned int when the code is dealing
with parser offsets, and to ints where it's not so clear.
    - ExpressionParse(): I have to add an explicit cast to assign TypeVoid
to VariableValue->Typ: (struct ValueType*)TypeVoid. It works.
- heap.c:
    - two casts to solve warnings for comparisons between ints and unsigned
ints. Thanks for HeapAllocMem!
- lex.c:
    - LexValue is not initialized with sufficient parameters: you are
missing at least two.
    - I had to cast TypeVoid as above
    - LexGetNumber(): I don't know why you cast Base to double in the loop
that picks up the exponent value -- it's unnecessary (and causes a warning!)
- picoc.h:
    - My compiler does not accept the PlatformVPrintf declaration: I
substituted "..." for "va_list Args". I haven't tested anything (yet), but
it compiles.
- platform.c:
    - int -> unsigned int comparison in PrintSourceTextErrorLine (the last
for()).
- variable.c:
    - int -> unsigned int comparison in VariableDereferencePointer() -- the
third "if".

So, lots of details, but mostly very small things.

- - -

I next tried using the interpreter. I am using it mostly in interactive
mode, where my main program opens a pipe to the interpreter and sends it
commands to execute -- the interpreter runs in a separate thread. For now,
I am only testing PicoC using the command line mode as I can't integrate
the new version in my stuff yet -- it's not ready.

I didn't keep a list of bugs I found -- I just fixed them as I went. I
guess it would have been useful to keep an "acid test" file... However, if
I try this:...

line1:    int fn( int a )
line2:    {
line3:    int b;
line4:    b=2;
line5:    return a+b;
line6:    }
line7:    printf( "%d\n", 1+fn(2) );

...it crashes in LexGetToken at line 613 because InteractiveCurrentLine is
NULL. I tried just invoking fn() and it crashes at the same place. I wonder
if you have the same problem, of if it's caused by something I changed?

However, if I squeeze the whole function declaration onto a single line,
there are no problems.

Original issue reported on code.google.com by zik.sale...@gmail.com on 5 Jun 2009 at 11:05

GoogleCodeExporter commented 9 years ago
Fixed? Must check.

Original comment by zik.sale...@gmail.com on 4 Oct 2009 at 4:55

GoogleCodeExporter commented 9 years ago
I don't have visual studio any more so I'm giving up on this for now.

Original comment by zik.sale...@gmail.com on 7 Nov 2009 at 7:58