The R Contributors community is running a book club on Modern C
This will be notes on chapter 1-3
Getting Started (C1)
Compiling and Running
So the book definitely assume that we’re running MacOS or Linux which is a bit problematic for me on windows…I think I just probably just figure out the correct R windows toolchain sooner rather than later…
Rtools43 is incompatible with previous versions since it relies on UCRT and not MSVCRT1
-
Rtools43 consists of Msys2 build tools, GCC 12/MinGW-w64 compiler toolchain, libraries built using the toolchain, and QPDF. Rtools43 supports 64-bit Windows and UCRT as the C runtime.
-
MSYS2 is a collection of tools and libraries providing you with an easy-to-use environment for building, installing and running native Windows software.
-
MSYS2 provides up-to-date native builds for GCC, mingw-w64, CPython, CMake, Meson, OpenSSL, FFmpeg, Rust, Ruby, just to name a few.
-
GCC (GNU Compiler Collection) is a free and open source compiler for C and C++ (and other languages like Objective-C, Fortran, D).
MinGW-w64 is a free and open source C library for targetting Windows 32-bit and 64-bit platforms.
The combination of these results in a free C/C++ compiler for Windows.I think I need to manually make this
Retrieve the latest source code via subversion:
export TOP_SRCDIR="$HOME/Downloads/R" svn checkout https://svn.r-project.org/R/trunk/ "$TOP_SRCDIR"
-
Should definitely follow the instructions above. One annoying this is I can’t figure out how to get .dotfiles to work with msys so I have manually export the gcc path.
The principle structure of a program (C2)
Grammar
- special words
- punctuation
- comments
- literals
- functions
- operators
Declarations and Definitions
Declarations do not specify the value OR where it can be found. Just what an identifier is supposed to represent.
int main(void);
double A[5];
size_t i;
Above is given as an example though I think it’s incorrect. The first is because it let’s the program figure out how to call main but does not define it. The second and 3rd are not because it actually allocates space at that time. You’d need to extern them. This could be specific to C++ though.