fb39ca4 / picoc

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

Compilation with Visual Studio Express 2010 #134

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. A number of small changes and the addition of some _win32 files results in 
this project successfully compiling and [mostly] running in Windows.
2. VS Warning level 4 emits a large number of warnings, mostly related to 
unreferenced formal paramaters. Rather than fix them, I turned it down to level 
3.
3. unistd.c - picoc expects a number of functions to be available that are in 
the unistd set, after a quick review, I excluded the .c file, but there were 
other refereces to functions that I commented out.
4. time.c - StdStrptime was commented out as well.
5. For maximum predictability to deeply embedded devices, I pondered creating 
c99 types (e.g. uint16_t, uint32_t, etc.), but didn't.
6. expression.c - line 1175. added ->Base to make VS compiler happy. "else if 
(VariableValue->Typ->Base == TypeVoid)"
7. Added #ifdef WIN32 and a block of code to picoc.c
8. Added #ifdef WIN32 and a small block to picoc.h
9. Added #ifdef WIN32 and a block of code to platform.c
10. Added #ifdef WIN32 and a block of code to platform.h
11. Refactored platform.h to conditionally include platform_XXX.h for what felt 
cleaner.
12. A few other minor changes (some typecasting) to reduce compiler warnings.

What is the expected output? What do you see instead?
Ran the test cases, and had 3 deviations:
1) 32_led - invalid operation on d[n++] = (int)(x%10L);
2) 42_function_pointer - bad type declaration on int (*f)(int) = &fred;
3) 46_grep - not an array on if "(argc == 2 && argv[1][0] ..."

I haven't dug into these 3 to assess why they deviated from expected results.

What version of the product are you using? On what operating system?
Latests picoc from svn read-only copy.
Windows XP.latest
Visual Studio Express C++ 2010

Please provide any additional information below.
Attached Zip is the full package.

Original issue reported on code.google.com by davesmar...@gmail.com on 4 Aug 2011 at 11:51

Attachments:

GoogleCodeExporter commented 8 years ago
Apologies - I meant for this to be an enhancement, not a defect report. Can't 
seem to change it now.

Original comment by davesmar...@gmail.com on 4 Aug 2011 at 11:52

GoogleCodeExporter commented 8 years ago
Hi Dave!
Thanks for sharing the Windows code (I was just in the process of making a 
Visual Studio C++ Express port myself)!

I have built and run your code with success!

I have looked into the 3 problems that you found (which I can replicate):

2) 42_function_pointer

This is not an issue as picoc does not support function pointer at this time 
(see Issue list). When looking at the test Makefile one can see that this test 
has been skipped.

3) 46_grep

Probably not an issue specifically for the Windows port. When looking at the 
test Makefile one can see that this test has been skipped.

1) 32_led 

This usse is caused by the exclusion of the '%' operator in platform_win32.h. 
By including the operator (line 6-10), by commenting out NO_MODULUS:

//#   define HEAP_SIZE C_HEAPSIZE
//#   define NO_FP
//#   define NO_CTYPE
//#   define NO_HASH_INCLUDE
//#   define NO_MODULUS

the test case works fine! I have commented out NO_CTYPE also as VC++ has ctypes.

I have detected one other minor issue:

cstdlib\time.c(46): warning C4047: '=' : 'void *' differs in levels of 
indirection from 'errno_t'

This is caused by the return type of gmtime_s in VC++ beeing errno_t instead of 
a pointer as on Unix. Probably not a big deal.

Jørgen

Original comment by jjohans...@gmail.com on 4 Oct 2011 at 11:44

GoogleCodeExporter commented 8 years ago
Hi Dave and Jørgen, thanks very much for your work on this.

I've just checked in revision #572 which adds a Visual Studio 2011 project. I 
haven't tested it much yet but it does seem to run. I'll finish it soon.

Original comment by zik.sale...@gmail.com on 5 Oct 2011 at 11:01

GoogleCodeExporter commented 8 years ago
Excellent! I have just checket out the latest from SVN and it builds and runs 
OK. A couple of comments:

- In platform.h I think there are two instances of 'extern jmp_buf ExitBuf;' 
that can be removed (line 58 and 77).

- platform_msvc.c seems to be missing the new debugger stuff.

- The included Visual Studio 2011 project can not be opened in Visual Studio 
C++ 2010 Express unfortunately (but is easy to recreate).

Jørgen

Original comment by jjohans...@gmail.com on 6 Oct 2011 at 9:11

GoogleCodeExporter commented 8 years ago
I believe this now works.

Original comment by zik.sale...@gmail.com on 24 Feb 2013 at 12:36

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi folks,

The following:
"cstdlib\time.c(46): warning C4047: '=' : 'void *' differs in levels of 
indirection from 'errno_t'
This is caused by the return type of gmtime_s in VC++ beeing errno_t instead of 
a pointer as on Unix. Probably not a big deal."

Could be fixed by creating the gmtime_r() under windows.

These is how the funtion are defined:
    Unix: gmtime_r(const time_t*, struct tm*)
    Win:  gmtime_s(struct tm*, const time_t*)

We could fix the problem by replacing in platform_win32.h:
#define gmtime_r gmtime_s
For:
struct tm *gmtime_r(const time_t *time, struct tm *result);

And add this function to platform_win32.c:

#include <time.h>
/* simulates gmtime_r under windows */
struct tm *gmtime_r(const time_t *time, struct tm *result)
{
   errno_t gmtime_error = gmtime_s(result, time);
   if (gmtime_error==0)
      return *result;
   else
      return NULL;
}

Thanks a lot for the good work,  I'm using this version compiled with GCC 
4.8.2, Cygwin64/Win8.1 and with VS2012/Win7 in another machine

Under Cygwin I did build picoc using the makefile from release 2.1 and I had to 
include debug.c in the make file, otherwise the program would not link.

Makefile:
TARGET  = picoc
SRCS    = picoc.c table.c lex.c debug.c parse.c expression.c heap.c \
    type.c variable.c clibrary.c platform.c include.c \
    platform/platform_unix.c platform/library_unix.c \
    cstdlib/stdio.c cstdlib/math.c cstdlib/string.c cstdlib/stdlib.c \
    cstdlib/time.c cstdlib/errno.c cstdlib/ctype.c cstdlib/stdbool.c \
    cstdlib/unistd.c
OBJS    := $(SRCS:%.c=%.o)

Regards,
Otto

Original comment by ofba...@gmail.com on 5 Apr 2014 at 5:42

Attachments: