Fatal error: No Target Architecture in Visual Studio
Use #include <windows.h>
instead of #include <windef.h>
.
From the windows.h
wikipedia page:
There are a number of child header files that are automatically included with
windows.h
. Many of these files cannot simply be included by themselves (they are not self-contained), because of dependencies.
windef.h
is one of the files automatically included with windows.h
.
No Target Architecture compilation error in Visual Studio using CMake
Since the error message mentioned a file of mine (e.g. file_operations.h
) I decided to define the architecture inside it using the following macro:
#define _AMD64_ 1
This fixed the problem but I believe that a "better" solution exists by configuring the CMakeLists.txt
or Visual Studio
.
Visual Studio Professional 2013, Update 5, No Target Architecture
In the end I found that removing the headers:
profileapi.h
sys/types.h
Resolved the issue and the project now builds without warning or error.
Thank you Dai, the better solution:
#include "targetver.h"
#include <Windows.h>
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <chrono>
#include <ctime>
#include <time.h>
#include <fstream>
#include <profileapi.h>
#include <sys/stat.h>
#include <sys/types.h>
how to solve #error : Must define a target architecture in wince mfc application?
Presumably, the error is because you're trying to build the application against the (desktop) Windows SDK. The easiest thing to do is to create a new "Win32 Smart Device" project and add your code to it.
Alternatively, check the "Compile for architecture" setting under project properties -> C/C++ and ensure that it is set for the appropriate architecture.
Include winnt.h in my project
check Compiler->Enable Microsoft extensions in Project options or use -Ze flag if you're compiling from the command line.
Related Topics
Why Aren't Static Const Floats Allowed
Converting Std::String to Std::Vector<Char>
How Will I Know Whether Inline Function Is Actually Replaced at the Place Where It Is Called or Not
Generating M Distinct Random Numbers in the Range [0..N-1]
Multiple Definition Error Including C++ Header File with Inline Code from Multiple Sources
The Intersection of Two Sorted Arrays
Difference in Behavior While Using Dynamic_Cast with Reference and Pointers
Should a Move Constructor Take a Const or Non-Const Rvalue Reference
How to Use an Array as Map Value
C++: When (And How) Are C++ Global Static Constructors Called
Populate an Array Using Constexpr at Compile-Time
How to Read Groups of Integers from a File, Line by Line in C++
Making a Template Parameter a Friend
Why Do We Need to Use 'Int Main' and Not 'Void Main' in C++