Psycho
Psycho

Reputation: 3

Error: file not recognized: File format not recognized c++

My Code:

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

int main() {
    cout << "hi my name is me" << endl;

    return 0;
}

I used the command:

:!g++ %

to compile my code

When it compiled it returned:
testing.cpp~: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
shell returned 1

Furthermore, this is my current bits/stdc++.h header file:

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

How do you fix this issue?

Upvotes: 0

Views: 3405

Answers (1)

paxdiablo
paxdiablo

Reputation: 881563

Assuming you're running this within vim, you're doing the right thing, as % gets replaced by the current file.

However, the fact that it's trying to compile testing.cpp~ (the vim backup for the testing.cpp file) indicates to me that you're editing the wrong file (or putting a ~ after the % on your command line).

Upvotes: 3

Related Questions