system and system2 in R [Software]
Hi Helmut,
❝ return 0;
It is about capturing the info that gcc prints, regardless of what that info is. Doesn't matter if it is error or success or a recipe for apple pie. When you ran the system command on hw.c, gcc probably gave you a message. It is that message (in your case that the compilation is successful) I need to capture in a variable.
Yes, I have been there prior to posting. Pipes, stdin, stdout and God knows what. I am too old for this.
❝ I tried this
❝
#include <stdio.h>
❝ int main() {
❝ return 0;
❝ }
saved ashw.c
❝ gcc-x86_64-w64 10.3.0 called from R 4.1.2:
❝
system(command = "gcc -Wall -O2 hw.c -o hw", intern = TRUE)
❝ character(0)
compiles tohw.exe
❝ In R 4.2.1:
❝
system(command = "hw", intern = TRUE)
❝ [1] "Hello, world!"
❝ Do I understand you correctly that you want to get eventual warnings / errors of the compiler in R? If yes, your approach cannot work. Since the file compiled successfully, R cannot ‘know’ of any problems.
It is about capturing the info that gcc prints, regardless of what that info is. Doesn't matter if it is error or success or a recipe for apple pie. When you ran the system command on hw.c, gcc probably gave you a message. It is that message (in your case that the compilation is successful) I need to capture in a variable.
❝ You have to tell the compiler to redirect them to a file and read it in R. Perhaps this thread at stackoverflow helps.
Yes, I have been there prior to posting. Pipes, stdin, stdout and God knows what. I am too old for this.

—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- system and system2 in R ElMaestro 2022-08-29 22:29 [Software]
- system and system2 in R Helmut 2022-08-30 01:10
- system and system2 in RElMaestro 2022-08-30 08:52
- system and system2 in R Helmut 2022-08-30 11:25
- processx package mittyri 2022-08-31 17:50
- system and system2 in RElMaestro 2022-08-30 08:52
- tryCatch in R mittyri 2022-08-31 17:53
- tryCatch in R ElMaestro 2022-09-01 10:33
- tryCatch in R mittyri 2022-09-01 14:07
- tryCatch in R ElMaestro 2022-09-01 10:33
- system and system2 in R Helmut 2022-08-30 01:10