EDIT2: Vấn đề là KHÔNG phải là lỗi đánh máy đơn giản. Tôi đã thực hiện một lỗi đánh máy trong các bản ghi dưới đây, mà tôi đã sửa chữa, nhưng vấn đề vẫn còn đó.Không thể biên dịch bất kỳ chương trình C++ nào; lỗi: tên loại không xác định 'uint8_t'
EDIT: Tôi đã chạy nhầm với gcc thay vì g ++, một lần, sau khi thử bên dưới. Vấn đề đã có trước đó với g + + và nó là có ngay bây giờ.
Tôi hiện đang ở trên hộp MacOS High Sierra. Gần đây tôi đã chuyển rất nhiều tập tin từ MacBook Air sang máy này, bao gồm những gì tôi cho là tất cả rác của Xcode. Bây giờ, khi tôi cố gắng để biên dịch một chương trình C++ rất đơn giản:
#include <iostream>
int main()
{
// VAR_DEC
int a = 4;
// VAR_MANIP
a = a*2;
// VAR_PRINT
std::cout << a << std::endl;
return 0;
}
tôi nhận được lỗi vô lý sau đây:
[email protected]: [config_file_script] $ g++ test.cpp -o test
In file included from test.cpp:1:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream:38:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/ios:216:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__locale:15:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/string:470:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/string_view:171:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/__string:56:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm:640:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/memory:629:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/typeinfo:61:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/exception:82:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/cstdlib:86:
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/stdlib.h:94:
In file included from /usr/include/stdlib.h:65:
In file included from /usr/include/sys/wait.h:110:
/usr/include/sys/resource.h:196:2: error: unknown type name 'uint8_t'
uint8_t ri_uuid[16];
^
/usr/include/sys/resource.h:197:2: error: unknown type name 'uint64_t'
uint64_t ri_user_time;
^
/usr/include/sys/resource.h:198:2: error: unknown type name 'uint64_t'
uint64_t ri_system_time;
^
/usr/include/sys/resource.h:199:2: error: unknown type name 'uint64_t'
uint64_t ri_pkg_idle_wkups;
^
/usr/include/sys/resource.h:200:2: error: unknown type name 'uint64_t'
uint64_t ri_interrupt_wkups;
^
/usr/include/sys/resource.h:201:2: error: unknown type name 'uint64_t'
uint64_t ri_pageins;
^
/usr/include/sys/resource.h:202:2: error: unknown type name 'uint64_t'
uint64_t ri_wired_size;
^
/usr/include/sys/resource.h:203:2: error: unknown type name 'uint64_t'
uint64_t ri_resident_size;
^
/usr/include/sys/resource.h:204:2: error: unknown type name 'uint64_t'
uint64_t ri_phys_footprint;
^
/usr/include/sys/resource.h:205:2: error: unknown type name 'uint64_t'
uint64_t ri_proc_start_abstime;
^
/usr/include/sys/resource.h:206:2: error: unknown type name 'uint64_t'
uint64_t ri_proc_exit_abstime;
^
/usr/include/sys/resource.h:210:2: error: unknown type name 'uint8_t'
uint8_t ri_uuid[16];
^
/usr/include/sys/resource.h:211:2: error: unknown type name 'uint64_t'
uint64_t ri_user_time;
^
/usr/include/sys/resource.h:212:2: error: unknown type name 'uint64_t'
uint64_t ri_system_time;
^
/usr/include/sys/resource.h:213:2: error: unknown type name 'uint64_t'
uint64_t ri_pkg_idle_wkups;
^
/usr/include/sys/resource.h:214:2: error: unknown type name 'uint64_t'
uint64_t ri_interrupt_wkups;
^
/usr/include/sys/resource.h:215:2: error: unknown type name 'uint64_t'
uint64_t ri_pageins;
^
/usr/include/sys/resource.h:216:2: error: unknown type name 'uint64_t'
uint64_t ri_wired_size;
^
/usr/include/sys/resource.h:217:2: error: unknown type name 'uint64_t'
uint64_t ri_resident_size;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Tôi đã thử cài đặt và cài đặt lại tất cả mọi thứ tôi có thể nghĩ ra có liên quan đến vấn đề như gcc
, g++
, cc
, brew
, Xcode, command-line-tools
, vv tôi cũng đã thử tất cả những gợi ý trên các trang sau:
- Unknown type name uint8_t?
- Include search path on Mac OS X Yosemite 10.10.1
- Cythonizing fails because of unknown type name 'uint64_t'
- unknown type name 'uint8_t', MinGW
- JT Bullitt's very comprehensive blog
và nhiều hơn nữa, nhưng những tóm tắt nó khá tốt. Không có giải pháp nào có hiệu quả.
Tôi nghĩ rằng the last one có giải pháp có khả năng nhất. (Nếu bạn tìm kiếm "không xác định" trên trang bạn sẽ thấy bản sửa lỗi.) Theo nhà phát triển:
Fix: Remove /opt/local/include/** and /opt/local/lib/** from the "Header Search Paths" build settings. Replace them with much more specific paths to the desired include directories. In my particular case, this meant replacing them with /opt/local/include/glib-2.0 /opt/local/lib/glib-2.0/include /opt/local/include/. It's up and running again!
Tuy nhiên, tôi không cài đặt Xcode, tôi chỉ cài đặt công cụ nhà phát triển dòng lệnh. Do đó, tôi không có cách dễ dàng để truy cập cài đặt xây dựng "Đường dẫn tìm kiếm tiêu đề" và do đó, tôi không thể thử giải pháp của mình.
Tôi đang tìm giải pháp cho vấn đề này, tốt nhất là không yêu cầu tôi cài đặt toàn bộ hệ điều hành. Ngoài ra, nếu ai đó có thể vui lòng hướng dẫn tôi thông qua việc tìm kiếm các tập tin cài đặt xây dựng, tôi sẽ rất biết ơn.
Nhận xét không dành cho thảo luận mở rộng; cuộc hội thoại này đã được [chuyển sang trò chuyện] (http://chat.stackoverflow.com/rooms/162198/discussion-on-question-by-joseph-farah-cannot-compile-any-c-programs-error-u) . –