mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 12:34:26 +01:00
c++ userland example
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
CFLAGS_EXTRA ?= -fopenmp -std=c99 -Wall -Werror -Wextra
|
CFLAGS_EXTRA ?= -fopenmp -std=c99 -Wall -Werror -Wextra
|
||||||
IN_EXT ?= .c
|
IN_EXT_C ?= .c
|
||||||
|
IN_EXT_CXX ?= .cpp
|
||||||
LIBS :=
|
LIBS :=
|
||||||
OUT_EXT ?= .out
|
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)
|
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||||
LIBS += -lopenblas
|
LIBS += -lopenblas
|
||||||
else
|
else
|
||||||
@@ -14,8 +15,11 @@ endif
|
|||||||
|
|
||||||
all: $(OUTS)
|
all: $(OUTS)
|
||||||
|
|
||||||
%$(OUT_EXT): %$(IN_EXT)
|
%$(OUT_EXT): %$(IN_EXT_C)
|
||||||
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||||
|
|
||||||
|
%$(OUT_EXT): %$(IN_EXT_CXX)
|
||||||
|
$(CXX) $(CXXFLAGS) $(CXXFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *'$(OUT_EXT)'
|
rm -f *'$(OUT_EXT)'
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ These programs can also be compiled and used on host.
|
|||||||
|
|
||||||
. Standalone
|
. Standalone
|
||||||
.. link:hello.c[]
|
.. link:hello.c[]
|
||||||
|
.. link:hello_cpp.cpp[]
|
||||||
.. link:myinsmod.c[]
|
.. link:myinsmod.c[]
|
||||||
.. link:myrmmod.c[]
|
.. link:myrmmod.c[]
|
||||||
.. link:sched_getaffinity.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