Jump to content

Visual Studio 2013 build issues


EttoreBarattelli

Recommended Posts

Hi all,

after a few attemps, I managed to get a "Hello World" Win32 project to compile and run on Visual Studio (the version I'm using is Visual Studio 2013, toolkit v120), but it did require a few changes in the uGFX library code.

The procedure I'm using is the following:

  • generate code (i.e. preview button in uGFX Studio) for a Hello World project (a simple container with a Label widget) from uGFX Studio (version 0.15 for Windows)
  • create a VS solution to compile both the uGFX library and the GUI code generated by uGFX Studio

To compile the library I'm using the "single file inclusion" method, therefore I just added the "gfx_mk.c" and "gdisp_lld_Win32.c" files (as well as "gui.c" and "main.c" generated by uGFX Studio) in the VS solution and set the include paths and preprocessor symbols accordingly.

Here the list of changes I had to apply to the uGFX library code:

  • file src/gos/gos_win32.c:
    • changed line 77:
//typedef LONG __stdcall (*_NtQuerySemaphore)(  // INITIAL
typedef LONG (__stdcall *_NtQuerySemaphore)(    // FIXED
  • file src/gos/gos_win32.c:
    • changed line 100:
//gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {  // INITIAL
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param) {      // FIXED
  • file src/gos/gos_win32.h:
    • changed lines 49-50:
//#define DECLARE_THREAD_FUNCTION(fnName, param)	threadreturn_t WINAPI fnName(void *param)    // INITIAL
//#define DECLARE_THREAD_STACK(name, sz)		uint8_t name[0];
#define DECLARE_THREAD_FUNCTION(fnName, param)		threadreturn_t (WINAPI fnName)(void *param)  // FIXED
#define DECLARE_THREAD_STACK(name, sz)			uint8_t name[sz];
  • file src/gos/gos_win32.h:
    • changed line 99:
//gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); // INITIAL
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param);     // FIXED
  • file src/gfx_compilers.h:
    • changed line 728:
//#warning "You are using an un-tested compiler. Please report any compile errors or warnings on the ugfx forum"         // INITIAL
#pragma message( "You are using an un-tested compiler. Please report any compile errors or warnings on the ugfx forum" ) // FIXED
  • file src/gfx_compilers.h:
    • changed line 901:
//#define GFXINLINE	inline        // INITIAL
#define GFXINLINE	__forceinline // FIXED

 

Obviously these changes are specific to Visual Studio and might (and probably will) break other compilers. If you like I can share the project with all resources (VS solution, updated uGFX library code, generated code for sample GUI).

 

Thanks,

Ettore

Link to comment
Share on other sites

Hello Ettore and welcome to the community!

Sorry for the late reply.
We appreciate this a lot. It's nice that you list everything in such a level of detail, nice work!
As you mentioned, these changes are very Visual Studio specific. Sadly we don't see a way (yet) to integrate them in an easy way without breaking support for other compilers or introducing a very ugly #ifdef mess. For the time being, we added a note to the documentation that points to this forum topic: http://wiki.ugfx.org/index.php/Win32

Keep up the good work!

Link to comment
Share on other sites

  • 11 months later...
  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...