system and system2 in R [Software]

posted by Helmut Homepage – Vienna, Austria, 2022-08-30 13:25 (1044 d 16:31 ago) – Posting: # 23243
Views: 4,261

Hi ElMaestro,

not sure why your original attempt failed.

A new one, missing the IO-declaration saved as FawltyTowers.c

int main() {
  printf("Hello, world!\n");
  return 0;
}

Then

x <- system(command = "gcc -Wall -O2 FawltyTowers.c -o FawltyTowers", intern = TRUE)
print(x)
[1] "FawltyTowers.c: In function 'main':"
[2] "FawltyTowers.c:2:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]"
[3] "    2 |   printf(\"Hello, world!\\n\");"
[4] "      |   ^~~~~~"
[5] "FawltyTowers.c:2:3: warning: incompatible implicit declaration of built-in function 'printf'"           
[6] "FawltyTowers.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'"
[7] "  +++ |+#include <stdio.h>"
[8] "    1 | int main() {"

The compiler is tolerant (warnings not a problem). FawltyTowers.c compiled successfully to FawltyTowers.exe, which differs from hw.exe only in the leading bytes at addresses 00088 and 000DB.

system(command = "FawltyTowers", intern = TRUE)
[1] "Hello, world!"


Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

UA Flag
Activity
 Admin contact
23,428 posts in 4,929 threads, 1,687 registered users;
57 visitors (0 registered, 57 guests [including 17 identified bots]).
Forum time: 05:57 CEST (Europe/Vienna)

To know that we know what we know,
and to know that we do not know what we do not know,
that is true knowledge.    Nicolaus Copernicus

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5