mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
c++ userland example
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
.PHONY: all clean
|
||||
|
||||
CFLAGS_EXTRA ?= -fopenmp -std=c99 -Wall -Werror -Wextra
|
||||
IN_EXT ?= .c
|
||||
IN_EXT_C ?= .c
|
||||
IN_EXT_CXX ?= .cpp
|
||||
LIBS :=
|
||||
OUT_EXT ?= .out
|
||||
|
||||
OUTS := $(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT))))
|
||||
OUTS := $(foreach IN_EXT,$(IN_EXT_C) $(IN_EXT_CXX),$(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT)))))
|
||||
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||
LIBS += -lopenblas
|
||||
else
|
||||
@@ -14,8 +15,11 @@ endif
|
||||
|
||||
all: $(OUTS)
|
||||
|
||||
%$(OUT_EXT): %$(IN_EXT)
|
||||
%$(OUT_EXT): %$(IN_EXT_C)
|
||||
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||
|
||||
%$(OUT_EXT): %$(IN_EXT_CXX)
|
||||
$(CXX) $(CXXFLAGS) $(CXXFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f *'$(OUT_EXT)'
|
||||
|
||||
@@ -10,6 +10,7 @@ These programs can also be compiled and used on host.
|
||||
|
||||
. Standalone
|
||||
.. link:hello.c[]
|
||||
.. link:hello_cpp.cpp[]
|
||||
.. link:myinsmod.c[]
|
||||
.. link:myrmmod.c[]
|
||||
.. link:sched_getaffinity.c[]
|
||||
|
||||
5
kernel_module/user/hello_cpp.cpp
Normal file
5
kernel_module/user/hello_cpp.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "hello world" << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user