-
-
Notifications
You must be signed in to change notification settings - Fork 727
Closed
Labels
jovian scopeThis is great but would be a huge undertaking and we have limited resourcesThis is great but would be a huge undertaking and we have limited resources
Description
First of all, great work hacking your way to platform independence!
Been just wondering if anyone made any attempts to use it in conjunction with the c++ standard library and if so, what does work and what doesn't ? - I'd expect that the standard library depends on some platform specific code, however it would be great if I could get started somewhere so I can start refactoring those bits.
I would love to package cosmopolitan for https://github.com/loopperfect/buckaroo or even built a beginner friendly SDK around this library.
My naive attempt to use cosmopolitan.h in a c++ project failed with a couple errors:
clang++ -std=c++20 \
-I/usr/include/c++/10 \
-I/usr/include/x86_64-linux-gnu/c++/10/ \
-I/usr/include/x86_64-linux-gnu/ \
-I/usr/include \
-Io\
-g -O -static -fno-pie -mno-red-zone -nostdlib -nostdinc -U__cplusplus -o hello.com main.cpp \
-Wl,--oformat=binary -Wl,--gc-sections -Wl,-z,max-page-size=0x1000 -fuse-ld=bfd \
-Wl,-T,o/ape.lds -include o/cosmopolitan.h o/libc/crt/crt.o o/ape/ape.o o/cosmopolitan.a
// hello.cpp
#include<cosmopolitan.h>
#include<vector>
int main() {
return 0;
}
errors:
In file included from <built-in>:1:
./o/cosmopolitan.h:284:24: error: cannot combine with previous 'int' declaration specifier
typedef __WCHAR_TYPE__ wchar_t;
^
./o/cosmopolitan.h:284:1: warning: typedef requires a name [-Wmissing-declarations]
typedef __WCHAR_TYPE__ wchar_t;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./o/cosmopolitan.h:285:9: error: 'char16_t' cannot be signed or unsigned
typedef __CHAR16_TYPE__ char16_t;
^
<built-in>:157:25: note: expanded from here
#define __CHAR16_TYPE__ unsigned short
^
In file included from <built-in>:1:
./o/cosmopolitan.h:285:9: error: 'short char16_t' is invalid
<built-in>:157:34: note: expanded from here
#define __CHAR16_TYPE__ unsigned short
^
In file included from <built-in>:1:
./o/cosmopolitan.h:285:1: warning: typedef requires a name [-Wmissing-declarations]
typedef __CHAR16_TYPE__ char16_t;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./o/cosmopolitan.h:286:25: error: cannot combine with previous 'int' declaration specifier
typedef __CHAR32_TYPE__ char32_t;
^
./o/cosmopolitan.h:286:1: warning: typedef requires a name [-Wmissing-declarations]
typedef __CHAR32_TYPE__ char32_t;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./o/cosmopolitan.h:7712:35: error: unknown type name 'int128_t'
int sleb128(const void *, size_t, int128_t);
^
./o/cosmopolitan.h:7713:37: error: unknown type name 'int128_t'
int unsleb128(const void *, size_t, int128_t *);
^
./o/cosmopolitan.h:21493:16: error: unknown type name 'jmp_buf'
void gclongjmp(jmp_buf, int) nothrow wontreturn paramsnonnull();
^
./o/cosmopolitan.h:21525:3: error: unknown type name 'jmp_buf'
jmp_buf jb;
^
In file included from main.cpp:2:
In file included from /usr/include/c++/10/vector:60:
In file included from /usr/include/c++/10/bits/stl_algobase.h:60:
/usr/include/c++/10/bits/functexcept.h:44:1: error: unknown type name '_GLIBCXX_BEGIN_NAMESPACE_VERSION'
_GLIBCXX_BEGIN_NAMESPACE_VERSION
^
/usr/include/c++/10/bits/functexcept.h:112:1: error: unknown type name '_GLIBCXX_END_NAMESPACE_VERSION'
_GLIBCXX_END_NAMESPACE_VERSION
^
/usr/include/c++/10/bits/functexcept.h:113:1: error: expected unqualified-id
} // namespace
^
In file included from main.cpp:2:
In file included from /usr/include/c++/10/vector:60:
In file included from /usr/include/c++/10/bits/stl_algobase.h:61:
/usr/include/c++/10/bits/cpp_type_traits.h:71:1: error: unknown type name '_GLIBCXX_BEGIN_NAMESPACE_VERSION'
_GLIBCXX_BEGIN_NAMESPACE_VERSION
^
/usr/include/c++/10/bits/cpp_type_traits.h:214:12: error: redefinition of '__is_integer<int>'
struct __is_integer<int>
^~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/cpp_type_traits.h:138:12: note: previous definition is here
struct __is_integer<bool>
^
/usr/include/c++/10/bits/cpp_type_traits.h:542:5: error: unknown type name '_GLIBCXX20_CONSTEXPR'
_GLIBCXX20_CONSTEXPR
^
/usr/include/c++/10/bits/cpp_type_traits.h:543:21: error: expected ';' at end of declaration
inline _Iterator
^
/usr/include/c++/10/bits/cpp_type_traits.h:544:18: error: unknown type name '_Iterator'
__miter_base(_Iterator __it)
^
/usr/include/c++/10/bits/cpp_type_traits.h:544:5: error: C++ requires a type specifier for all declarations
__miter_base(_Iterator __it)
^
/usr/include/c++/10/bits/cpp_type_traits.h:547:1: error: unknown type name '_GLIBCXX_END_NAMESPACE_VERSION'
_GLIBCXX_END_NAMESPACE_VERSION
^
/usr/include/c++/10/bits/cpp_type_traits.h:548:1: error: expected unqualified-id
} // namespace
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 warnings and 20 errors generated.
``hdclark, l1ghtn1ngth1ef, fabiospampinato, lganzzzo, mmaulwurff and 2 more
Metadata
Metadata
Assignees
Labels
jovian scopeThis is great but would be a huge undertaking and we have limited resourcesThis is great but would be a huge undertaking and we have limited resources