Import multiple libs into a single include in c

2

Is there a way to import all libs from my program into just include like in other languages: import re, datetime, math (Python)?

After reading about preprocessing directives here (Little is said about the include on this Wiki page) I thought of something like import the default system libs ( stdio, stdlib, stdbool, string, locale ...) as external libs " stdio.h, stdlib.h " , but I do not think there is a (or do not know) a delimiter to put between them so that it works correctly ... just out of curiosity even if someone knew would be grateful.

In addition to the Wikipedia article: Cpp Reference Preprocessor >     

asked by anonymous 16.06.2017 / 18:16

1 answer

2

It does not exist; the preprocessor C is a rather primitive macro language, and little integrated with the rest of the language (such as Dennis Ritchie himself.) affirms ).

What you can do is create a separate header file that includes all the standard headers you want to include, usually called common.h or config.h :

#ifndef DEFINICOES_DE_CABECALHO
#define DEFINICOES_DE_CABECALHO

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdarg.h>
#include <stdint.h>
#include <time.h>
#include <locale.h>

#endif

And then, in your source files, just say

#include "common.h" // ou "config.h", ou qualquer nome que você tenha escolhido
    
16.06.2017 / 18:32