Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22476

converting .c file to .o using processes

$
0
0

I have to make a project which asks me to create a program that will compile a C project by recursively descending into directories and launching processes which compile a file of code by calling GCC and look through directories and launch a new process for every ".c" file in the current directory that process will call gcc on the .c file making a .o file.

I have written this code so far to list the directories firstI am having trouble checking what files are .c and how to convert them to .o

can someone help me with some relevant information/links that I can refer to? void listdir(const char *name, int indent){    DIR *dir;    struct dirent *entry;    if (!(dir = opendir(name)))        return;    while ((entry = readdir(dir)) != NULL) {        if (entry->d_type == DT_DIR) {            char path[1024];            if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)                continue;            snprintf(path, sizeof(path), "%s/%s", name, entry->d_name);            printf("%*s[%s]\n", indent, "", entry->d_name);            listdir(path, indent + 2);        } else {            printf("%*s- %s\n", indent, "", entry->d_name);        }    }    closedir(dir);}int main(void) {    listdir(".", 0);    return 0;}

Viewing all articles
Browse latest Browse all 22476

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>