system and system2 in R [Software]

posted by Helmut Homepage – Vienna, Austria, 2022-08-30 13:25 (577 d 01:23 ago) – Posting: # 23243
Views: 1,654

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
22,957 posts in 4,819 threads, 1,636 registered users;
123 visitors (0 registered, 123 guests [including 2 identified bots]).
Forum time: 13:49 CET (Europe/Vienna)

With four parameters I can fit an elephant,
and with five I can make him wiggle his trunk.    John von Neumann

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