Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Include From Internet

I want include a header from internet. For example: file add.h and add.cpp have been post to github.com

file add.h is int add(int a,int b);

file add.cpp is int add(int a,int b){return a+b;}

in my main.cpp I want the code like this

#include "github.com/xxx/add.h"
int main(){
int a = add(1,1);
}

When compile begin,compiler can auto download add.cpp from github.com

Can this happen?

like image 760
bitnick Avatar asked Jun 27 '15 08:06

bitnick


1 Answers

No it's not going to happen (assuming you're not using some sort of fetching machinery). Only local files are included by the preprocessor with an #include directive.

C++ doesn't work like Go or Javascript

Files hosted on github are meant to be checked out using git and then used.

I recommend reading a C++ and a Git book before continuing (or your compiler/build system manual to add extra fetching steps)

like image 101
Marco A. Avatar answered Oct 22 '22 20:10

Marco A.