473,698 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Porting from MSVC to GCC, vague errors

12 New Member
As the title says, I am porting some code from MSVC (not sure which version, using Visual Studio 2008), which compiles without errors or warnings, to GCC 4.0 which generates a large number of generic errors.

The project uses a large header file 'precompiled.h' which includes two other header files, math/math.h and math/vector.h in that order. I've already disabled the ALWAYS_SEARCH_U SER_PATHS which was causing other errors.

From math/math.h

Expand|Select|Wrap|Line Numbers
  1. class qMath {
  2. public:
  3. ...
    static float Fabs( float x );
    ...
  4. };
  5.  
  6. inline float qMath::Fabs( float x ) {
  7. ...
    return x;
    }
  8.  
From math/vector.h

Expand|Select|Wrap|Line Numbers
  1. inline bool qVec2::Compare( const qVec2 &a, const float epsilon ) {
  2. // the following is line 106
    ( qMath::Fabs( x - a.x ) > epsilon )
    ...
Which generates the following errors:

../math/Vector.h:106: error: 'qMath' has not been declared
../math/Vector.h:106: error: 'Fabs' was not declared in this scope

And the same sort of errors wherever qMath is referenced.

Been mucking around with this for awhile now and haven't gotten anywhere, any help would be appreciated.
Nov 10 '08 #1
17 6902
boxfish
469 Recognized Expert Contributor
I doubt I can be of any help with this, but maybe you could post your makefile? It sounds like a problem with either your includes or your makefile.
Nov 11 '08 #2
qartar
12 New Member
I'm using Xcode as my development environment and I'm not sure where exactly to view the makefile. It fails while trying to create the precompiled header object /precompiled.h.g ch, which is the first object being compiled.

By using the -H compiler flag I can see that the headers are being added in the correct order, and errors are not generated until after all the headers have been included. Since this the code compiles without errors in MSVC I'm assuming it's something specific with GCC.
Nov 11 '08 #3
boxfish
469 Recognized Expert Contributor
Okay, I see, sorry. I had thought you were just using a text editor, writing the makefiles by hand, and running gcc from the shell.
Nov 11 '08 #4
Banfa
9,065 Recognized Expert Moderator Expert
Is there a namespace declared in Math.h containing qMath? If so then

qMath::Fabs

needs to be

<NameSpace>::qM ath::Fabs

It is less likely to be something specific with GCC so much as some wired MS extension causing the code to compile when it shouldn't.
Nov 11 '08 #5
qartar
12 New Member
Not using any namespace declarations.
Nov 11 '08 #6
qartar
12 New Member
If it is because of MS specific extensions it is near impossible for me to tell which or why since disabling their extensions prevents even their standard header files from compiling.
Nov 11 '08 #7
Banfa
9,065 Recognized Expert Moderator Expert
Yes I know quite irritating isn't it :7

Hmmm, given what we can see of your code all I can say is that for some reason (when using GCC) at the time that vector.h is parsed the declarations in Math.h have not been parsed so the compiler does not know about qMath (Vector.h isn't included into Math.h is it?).

You can test this by forward declaring qMath
class qMath;
at the top of vector.h, this will not solve the problem but it should give different errors (incomplete type).
Nov 11 '08 #8
qartar
12 New Member
Yes I know quite irritating isn't it :7

Hmmm, given what we can see of your code all I can say is that for some reason (when using GCC) at the time that vector.h is parsed the declarations in Math.h have not been parsed so the compiler does not know about qMath (Vector.h isn't included into Math.h is it?).

You can test this by forward declaring qMath
class qMath;
at the top of vector.h, this will not solve the problem but it should give different errors (incomplete type).
That is what I suspected even though, as I said, the headers are included in the correct order. I've actually already tried forward declaring qMath which generates the incomplete type errors you predicted. I'm about at wit's end trying to understand what could be wrong here.

I suppose it interesting that the error that I get about qMath is slightly different than those generated by other unrecognized symbols, I'm not sure if this is just because it is interpreted as a scoping symbol or what...

Compare:
/qlib/math/Vector.h:106: error: 'qMath' has not been declared
/qlib/Str.h:330: error: 'sprintf_s' was not declared in this scope

Second error is an easy fix, added just for reference here.

Edit: I forgot to mention that I've also tried to include math.h directly from vector.h which changes nothing from the original compilation routine. Can the qMath class be being ignored by gcc without generating warnings or errors or something of that nature?
Nov 11 '08 #9
Banfa
9,065 Recognized Expert Moderator Expert
No GCC would not be ignoring qMath for no reason without a diagnostic.

Can you post the preprocessor commands from each file please (2 headers and a cpp I presume).
Nov 11 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4376
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two files containing some templates: adjacency_list.hpp and mem_fn.hpp can not compile. Does anyone have any solutions?
2
1645
by: brckcc | last post by:
I've got a managed extension library that I'm attempting to convert from MSVC 2003 to MSVC 2005. I've converted the project file and am now attempting to compile the application. I get multiple occurrences of the following linker errors: extern "C" void __clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)" (?___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z) referenced in
2
1327
by: Edson Tadeu | last post by:
When using an external tool to build (e.g NMAKE), the output window now prepends '1>' in each line. Also, the errors and warnings are not appearing on the task list anymore (as opposed to MSVC 2003). How do I get rid of this and get the errors back in the task list?
23
2405
by: Babak | last post by:
Hi Everyone, I've written a standard C code for a simple finite element analysis in MSVC++ . When I save the file as a cpp file, it compiles and runs perfectly, but when I save it as a c file, there are lots of errors and warnings in compiling stage. I am really confused about this problem because I'm not even familiar with C++ and my code only includes simple C functions. Can anybody please tell me what's my mistake? Is there any other...
34
4055
by: subramanian100in | last post by:
Is there any difference between porting and migrating. Kindly explain
133
4181
by: Jean-Pierre Mestre | last post by:
Good evening, I have a C software for Windows that I need to port to Redhat Unix. At the moment it works completely fine with the Windows FLOSS compiler lccwin32. I try gcc but now it doesn't work :( There seems to be two serious problems, one operator overloading and the other the safe String type. Is there a compiler for Unix with these advanced features, or what's the best way to port them across?
1
1679
by: Jim Langston | last post by:
I'm trying to compile some source code to interface LUA into C++. When I compile in MSVC++ Express 2008, however, I get the error (among others): ....\luastate.h(129) : error C2027: use of undefined type 'cpplua::LuaFunction' ....\luastate.h(63) : see declaration of 'cpplua::LuaFunction' So I'm trying to track this down. I see that there is a function trying to return LuaFunction Like this:
47
2355
by: =?Utf-8?B?ZW1hdmlzdQ==?= | last post by:
Dear guys, I'm in trouble having to port my project from C++Builder6 to VisualC++. Has anyone of you idea if there are any tools to help my doing this job? My current project is widely using VCL and these 2 IDE (C++Builder and VisualC++) seems to be so far each other that I can hardly think to find out a tool to "automatically" perform something for me. Thank you.
3
10812
by: imaloner | last post by:
I am posting two threads because I have two different problems, but both have the same background information. Common Background Information: I am trying to rebuild code for a working, commercially sold application with only partial build instructions. The previous maintainer of the code (a mixture of C and C++) is no longer with the company, but when he built the code he used MSVC++, and though I am not certain of the version he was ...
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.