Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8447157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:07:00+00:00 2026-06-10T10:07:00+00:00

I’m currently using both Visual Sstudio 2010 and Eclipse+MinGW for my C++ project. I’ve

  • 0

I’m currently using both Visual Sstudio 2010 and Eclipse+MinGW for my C++ project. I’ve experienced different compiler behaviors, which needs your kind explanation. Here are one example:

Suppose I have a.h and a.cpp. And I have pre-compiled header file (i.e., stdafx.h in VS, and precomp.h in Eclipse (I created one for Eclipse)). I’m gonna include some basic header files in the pre-compiled header file (e.g., core.hpp in opencv). And in both a.h and a.cpp, I will use some classes (e.g., Mat in opencv) declared in the basic header files which are included in the pre-compiled header.

For Visual Studio 2010, I have to put stdafx.h in every .cpp file (as in the link). So in a.cpp, I have this in the begining:

#include "stdafx.h"
#include "a.h"

Besides, I don’t include stdafx.h in a.h. I was expecting the error that the compiler cannot find the class declared in the basic header files, but it turns out the compilation is just fine under VS. There are no errors at all.

For Eclipse+MinGW, I do like this: in a.h, I put #include "precomp.h" at the begining. And in a.cpp, I only put #include "a.h" (As told by some friends, this is the C++ standard way to include header files). After compilation, this is no error, which is of no doubt. But if I do it similarly as what I did for Visual Studio, i.e., I don’t include precomp.h in a.h. There will be errors, indicating some classes are not declared in this scope. As concerned by @MSalters, I should **highlight** that both a.h and a.cpp contain proper declarations and definitions.

So anyone can help explain the difference bahaviors of VS and Eclipse+MinGW to me? Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:07:02+00:00Added an answer on June 10, 2026 at 10:07 am

    Precompiled headers are an efficiency measure. The code should still be valid if the compiler would compile them using the normal methods. In particular, your Visual C++ code should compile on Eclipse and vice versa.

    I strongly suspect your problem is on the Eclipse side. Why is a.cpp virtually empty? It should contain the definition for all declaractions in a.h.

    If you’re including “precomp.h”, it probably should come before the contents of “a.h”. There are essentially two ways of achieving that. One is to include both headers in that order (Visual Studio style) and the other is to include “precomp.h” before any declaration in “a.h”. (MinGW style)

    The rules for precompilation are somewhat more relaxed in MinGW as it pre-compiles less. That

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.