From ddcf04837376db8429549125db7e48a5d6986e54 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Fri, 21 Jan 2022 10:08:44 -0800 Subject: [PATCH] Updated Frequently asked Questions for using Raylib with C Plus Plus (markdown) --- ...ently-asked-Questions-for-using-Raylib-with-C-Plus-Plus.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Frequently-asked-Questions-for-using-Raylib-with-C-Plus-Plus.md b/Frequently-asked-Questions-for-using-Raylib-with-C-Plus-Plus.md index 50879fd..1e6117e 100644 --- a/Frequently-asked-Questions-for-using-Raylib-with-C-Plus-Plus.md +++ b/Frequently-asked-Questions-for-using-Raylib-with-C-Plus-Plus.md @@ -1,14 +1,18 @@ This page will go over some of the common questions new users of Raylib have when using C++. * How do I use Raylib with C++? + Raylib works with C++ in the exact same way it does with the C language. You can use Raylib from C++ with no special modifications or build steps. Simply include Raylib for your compiler and platform in the exact same way you do for C. Raylib is fully compatible with both C and C++. * Do I have to use Raylib-CPP to use Raylib with C++? + No, Raylib-CPP is not required to use Raylib with C++. Raylib-CPP is an optional wrapper that sits on top of the regular C Raylib in order to provide object oriented access to Raylib. Raylib-cpp still calls the same C Raylib in the end. * I Get an error on code like this when building an example in C++ `(Vector3){1.0f,2.0f,3.0f}`. How Can I fix it? + This type of structure initialization `(Vector3){1.0f,2.0f,3.0f}` is called a compound literal and is not supported by C++. Some C++ compilers are strict and will not allow it. This code can be converted to brace initialization in C++ by simply removing the parentheses around the type. Changing the code to `Vector3{1.0f,2.0f,3.0f}` will fix the error. This change needs to be made for code that is pulled from the Raylib C examples. * DrawText takes a const char*, but I have a std::string, how can I draw my string? + std::string has a method named c_str(), this will return the const char* stored in the string, use it as the argument for any C function that takes a const char*. `DrawText(my_string.c_str(),0,0,20,RED);`