Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot compile any C++ programs; error: unknown type name 'uint8_t'

EDIT2: The problem was NOT a simple typographical error. I made a typo in the logs below, which I corrected, but the problem was still there.

EDIT: I mistakenly ran with gcc instead of g++, once, after attempting below. The problem was there before with g++ and it is there now.

I am currently on a MacOS High Sierra box. I recently moved a lot of files from a MacBook Air to this machine, including what I assume were all of Xcode's junk. Now, when I try to compile a very simple C++ program:

#include <iostream>

int main()
{
    // VAR_DEC
    int a = 4;
    // VAR_MANIP
    a = a*2;
    // VAR_PRINT
    std::cout << a << std::endl;
    return 0;
}

I get the following ridiculous error:

jrfarah@Josephs-MBP: [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.

I've tried installing and reinstalling everything I could think of related to the problem, such as gcc, g++, cc, brew, Xcode, command-line-tools, etc. I've also tried all the suggestions on the following pages:

  • 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

and more, but those summarize it pretty well. None of the solutions have worked.

I think the last one has the most likely solution. (If you search for "unknown" on the page you'll see the fix.) According to the developer:

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!

However, I didn't install Xcode, I only installed the command line developer tools. Therefore, I don't have an easy way to access the "Header Search Paths" build settings, and thus, I can't try out his solution.

I am looking for a solution to this problem, preferably one that doesn't require me installing the entire OS. Alternatively, if someone could kindly guide me through finding the build settings file, I would be very grateful.

like image 932
Joseph Farah Avatar asked Dec 29 '17 22:12

Joseph Farah


People also ask

Where is uint8_t defined in C?

In C, the unsigned 8-bit integer type is called uint8_t . It is defined in the header stdint. h . Its width is guaranteed to be exactly 8 bits; thus, its size is 1 byte.

Which library contains uint8_t?

My LCD library uses uint8_t types.

What is the difference between Uint8 and uint8_t?

The difference between Uint8 and uint8_t will depend on implementation, but usually they will both be 8 bit unsigned integers. Also uint8_t and uint16_t are defined by C (and maybe C++) standard in stdint. h header, Uint8 and Uint16 are non-standard as far as I know.

What is uint32_t in C?

uint32_t is a numeric type that guarantees 32 bits. The value is unsigned, meaning that the range of values goes from 0 to 232 - 1. This. uint32_t* ptr; declares a pointer of type uint32_t* , but the pointer is uninitialized, that is, the pointer does not point to anywhere in particular.


1 Answers

Maybe you can try:

mv /usr/local/include /usr/local/include.old

then:

brew install llvm

like image 87
Chengcheng Zhang Avatar answered Sep 21 '22 13:09

Chengcheng Zhang