New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 723 - Warnings due to missing abs() overloads when compiling for Windows CE 6.0
Summary: Warnings due to missing abs() overloads when compiling for Windows CE 6.0
Status: RESOLVED DUPLICATE of bug 619
Alias: None
Product: Eigen
Classification: Unclassified
Component: General (show other bugs)
Version: 3.2
Hardware: Other Windows
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.3
  Show dependency treegraph
 
Reported: 2014-01-08 06:31 UTC by Richard Lang
Modified: 2014-09-07 17:04 UTC (History)
3 users (show)



Attachments

Description Richard Lang 2014-01-08 06:31:10 UTC
Trying out Eigen v3.2.0 with a Windows CE 6.0 application, compiled with Visual Studio 2008.  The eigen project's changelog has some entries that seem to indicate that Windows CE compatibility has been given some consideration.

Inserted the following code into an existing cpp source module:


#include <stdafx.h>

#include <Eigen\Dense>


using namespace Eigen;

...

    float Vmid1, Vmid2, Vmid3, I1, I2, I3;

...


        Matrix3f A;

        A <<    I1, I1, 1,
                I2, I2, 1,
                I3, I3, 1;

        Vector3f b;

        b << Vmid1, Vmid2, Vmid3;

        Vector3f x = A.colPivHouseholderQr().solve(b);


Our target platform is set up to cross compile for both target platform (Windows CE 6.0 on ARM926EJ-S) and desktop Windows.  Compiling for desktop completes without warnings, but when compiling for target get the following warnings:

1>c:\rac 900 software\rac-717 sensing cross-functional sprint\health\external\eigen\src/QR/ColPivHouseholderQR.h(496) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
1>c:\rac 900 software\rac-717 sensing cross-functional sprint\health\external\eigen\src/QR/ColPivHouseholderQR.h(496) : warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data
1>c:\rac 900 software\rac-717 sensing cross-functional sprint\health\external\eigen\src/QR/ColPivHouseholderQR.h(496) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data



Looking at ColPivHouseholderQR.h line 496


    if(abs(beta) > m_maxpivot) m_maxpivot = abs(beta);

Turns out that Windows CE (6.0 at least) is missing the the overloaded abs() definitions for long, float and double types that in desktop VS C++ environment are defined in ".\Microsoft Visual Studio 9.0\VC\include\math.h" and compiler is quite rightly warning on implicit type conversion required to invoke int abs(int).

Got things compiling OK by creating a header file named eigen_wince.h with the following content copied from ".\Microsoft Visual Studio 9.0\VC\include\math.h"

#pragma once

#ifndef __cplusplus
#error
#endif

#ifndef _WIN32_WCE
#error
#endif

#define EIGEN_MALLOC_ALREADY_ALIGNED TRUE

#include <yvals.h>

_STD_BEGIN

// Windows CE is missing the overloads of abs() for long, float, double etc. that are expected by Eigen library.  On desktop Windows these are
// defined in math.h
inline long __CRTDECL abs(_In_ long _X){return (labs(_X)); }
inline double __CRTDECL abs(_In_ double _X){return (fabs(_X)); }
inline float __CRTDECL abs(_In_ float _X){return (fabsf(_X)); }
inline long double __CRTDECL abs(_In_ long double _X){return (fabsl(_X)); }

_STD_END


and #including it before any eigen headers.

No idea if this is a problem with more recent CE versions (7.0 and 2013).

thanks

Richard
Comment 1 Christoph Hertzberg 2014-09-07 17:04:22 UTC

*** This bug has been marked as a duplicate of bug 619 ***

Note You need to log in before you can comment on or make changes to this bug.