FOX howto

From Open Watcom

Jump to: navigation, search

Compiling FOX-1.7.16 using OW 1.7

Just One Little Problem

The only issue preventing the FOX library from compiling "out of the box" is a problem that the OW 1.7 C++ compiler has with overloaded template function resolution.


This only affects the file include/FXElement.h.


A typical error message is:-

FXAccelTable.cpp(80): Error! E651: col(12) cannot instantiate allocElms
..\include\FXElement.h(84): Note! N649: col(15) template function
'bool FX::allocElms( ? * &, unsigned long )' defined in: ..\include\FXElement.h(84) (col 15)

The problem is that the template function is called with the second argument as long or int or unsigned int and the OW 1.7 C++ compiler will not match these with the unsigned long.


My solution is to add template functions that exactly match the requested parameter type and then cast the parameter in a call to the original function. For example:-

// Original function
template<class EType>
inline FXbool allocElms(EType*& ptr,unsigned long n){
  return fxmalloc((void**)&ptr,sizeof(EType)*n);
  }
// My additions
template<class EType>
inline FXbool allocElms(EType*& ptr,int n){
  return allocElms(ptr, (unsigned long)n);
  }
template<class EType>
inline FXbool allocElms(EType*& ptr,unsigned int n){
  return allocElms(ptr, (unsigned long)n);
  }
template<class EType>
inline FXbool allocElms(EType*& ptr,unsigned short n){
  return allocElms(ptr, (unsigned long)n);
  }

(Repeat this about 20 times for various failed instantiations.)


This is not a great solution, but it is easy and all changes are limited to this one file. If someone knows a better way, please replace this rubbish! :)


Note that the new, improved OW C++ compiler will not have this problem.

Makefiles

Makefiles for OpenWatcom are included (though not for all samples) and should work, though they are not always properly updated on new releases of the FOX library. Sometimes object filenames are misspelt or left out. Some attention should be given to CXXFLAGS and LDFLAGS in case these are not suitable for you. My personal preferences are:-

CXXFLAGS  = /w3 /e1 /zq /zmf /5r /ei /xs /xr /fp5 /otexan
LDFLAGS   = -"OPTION EL" -l=nt_win


Openwatcom makefiles are named Makefile.wc

There is not (yet?) a makefile that makes everything, so we need to visit some directories and wmake -f makefile.wc

First these:-

  • FOX-1.7.16\src
  • FOX-1.7.16\utils


Then (optionally) these:-

  • FOX-1.7.16\tests
  • FOX-1.7.16\adie
  • FOX-1.7.16\calculator
Personal tools