Fix a bunch of MSVC compiler warnings and errors.

Most notably, we need to actually fix a bug in MSVC that doesn't know how to properly instantiate
enums in partial template specialization. There are more details outlined here:

http://stackoverflow.com/questions/15466594/why-does-msvc-fail-to-compile-this-template-function

The fix in this commit closes #10

Also in this commit is a hacky way to allow GL defines. Apparently "LoadImage" is defined as a
macro even with WIN32_LEAN_AND_MEAN. This means that we have to #undef the code that includes
it, meaning that we also need to make sure not to actually mix GLDefines.h with any file that needs
to use the functions from Windows.h
This commit is contained in:
Pavel Krajcevski 2014-03-12 02:43:09 -04:00
parent 0eae5548a3
commit 479ba8e76d
6 changed files with 13 additions and 12 deletions

View File

@ -73,7 +73,7 @@ namespace FasTC {
// principal eigenvector. However, that may be due to
// poor initialization of the random vector, so rerandomize
// and try again.
const float newBlen = newB.Length();
const T newBlen = newB.Length();
if(newBlen < 1e-10) {
if(badEigenValue) {
eigVec = b;

View File

@ -183,9 +183,10 @@ namespace FasTC {
return a;
}
// !WTF! MSVC bug with enums in template parameters =(
template<
EVectorType kVectorTypeOne,
EVectorType kVectorTypeTwo,
/* EVectorType */unsigned kVectorTypeOne,
/* EVectorType */unsigned kVectorTypeTwo,
typename TypeOne,
typename TypeTwo>
class MultSwitch {

View File

@ -53,7 +53,7 @@
#include "gtest/gtest.h"
#include "MatrixBase.h"
static const float kEpsilon = 1e-6;
static const float kEpsilon = 1e-6f;
TEST(MatrixBase, Constructors) {
FasTC::MatrixBase<float, 3, 4> m3f;
@ -123,7 +123,7 @@ TEST(MatrixBase, PointerConversion) {
}
TEST(MatrixBase, CastVector) {
srand(time(NULL));
srand(static_cast<unsigned>(time(NULL)));
FasTC::MatrixBase<float, 3, 2> v3f;
for(int i = 0; i < 6; i++) {

View File

@ -53,7 +53,7 @@
#include "gtest/gtest.h"
#include "VectorBase.h"
static const float kEpsilon = 1e-6;
static const float kEpsilon = 1e-6f;
TEST(VectorBase, Constructors) {
FasTC::VectorBase<float, 3> v3f;
@ -173,7 +173,7 @@ TEST(VectorBase, Normalization) {
EXPECT_EQ(v2u[0], 1);
EXPECT_EQ(v2u[1], 1);
const float sqrt2 = sqrt(2)/2.0f;
const double sqrt2 = sqrt(2)/2.0f;
for(int i = 2; i < 10; i++) {
v2f[0] = static_cast<float>(i);
v2f[1] = static_cast<float>(i);

View File

@ -59,12 +59,7 @@
#include "TexComp.h"
#include "ThreadSafeStreambuf.h"
#ifdef _MSC_VER
int _tmain(int argc, _TCHAR* argv[]) {
#else
int main(int argc, char **argv) {
#endif
if(argc != 3) {
fprintf(stderr, "Usage: compare <img1> <img2>\n");
return 1;

View File

@ -57,6 +57,11 @@
# ifdef __APPLE__
# include <OpenGL/gl.h>
# else
# ifdef _MSC_VER
# define WIN32_LEAN_AND_MEAN
# include "Windows.h"
# undef LoadImage
# endif
# include <GL/gl.h>
# endif
#endif