1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <string.h>
#include "clog.h"
// ⚠ This might make a mess, i.e., make it harder to call the real GCC. We'll see...
#define _strings_match(s1, s2) (strcmp((s1), (s2)) == 0)
int main(int argc, char* argv[]) {
// Assume that the command is always called as:
// gcc -o «executable» «▒▒▒.c»
// This won't be perfect at first. We will walk through some pitfalls.
//
// THIS IS BUGGY (SO FAR)
if(!_strings_match(argv[1], "-o")) {
fprintf(stderr, "First argument must be \"-o\"\n");
}
if(strlen(argv[2]) == 0) {
fprintf(stderr, "Second argument must not be blank.\n");
}
// Make sure the .c file ends with .c
if(argv[3][strlen(argv[3]) -2] != '.' || argv[3][strlen(argv[3]) - 1] != 'c') {
// ‾‾‾‾‾‾‾‾‾‾‾‾‾‾△‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾△‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// Is second to last character a period Is last character a 'c'.
fprintf(stderr, "Third argument must end with .c\n");
}
printf("# TODO: Compile %s to create executable %s.\n", argv[3], argv[2]);
return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */
|
© Copyright 2020 Alexander J. Quinn This content is protected and may not be shared, uploaded, or distributed.