Anonymous
So how can i do that Even i use fseek it only append from start
https://en.cppreference.com/w/c/io/fopen Is it so hard to read docs?
Anonymous
But not found
Anonymous
I think you didn't understand my question
Anonymous
I did
Anonymous
Read the docs
Anonymous
Ok
Prince Of Persia
How to scanf a register?
Anonymous
How to scanf a register?
Assembly registers are not readily accessible without using asm
Ammar
I mean register keyword
You can't, scanf needs memory access. Register is not a memory location.
Anonymous
I mean register keyword
Register suggests to use a register but doesn't force it. The compiler can refuse to use the register. A register int cannot be used with pointers though. So you can't address it in the standard way
Ammar
Simply because you can't take address of register. register int a; You can't use &a.
Ammar
Simply because you can't take address of register. register int a; You can't use &a.
Though the compiler may put the a on memory, because register here is only a hint, unless you explicitly specify which register you are going to use. Semantically you can't take address of variable that is declared as register.
Ammar
If you specify it like this register int a asm("eax"); Then a will always be eax, compiler is not allowed to assume the variable as another register nor memory anymore.
ברני
I don't know, either. But, just curious, what exactly you mean by "stuff"?
I have alot of ideas that can be sell and be a good product in the industry
Anonymous
This is the way to force the compiler to use register, you can even specify which register. https://godbolt.org/z/c8Kf9fb5K
This is an extension of GCC if I recall correctly. By the way: the compiler will do this for you. Not considering special cases, the compiler knows better when to use a register. If you want to force the register, follow the message I'm replying to
Ilya
Not at all. While programming Linux kernel modules, you may want to trace your program in runtime (via eBPF, for example) some registers (especially which are used to pass the arguments to the functions).
Anonymous
Using the register keyword or not, will not alter the core of debugging in kernel development
Ilya
It is not debugging
Ilya
https://ebpf.io/
Ilya
C++ programmers cant program Linux modules
Ilya
Only C
Anonymous
You are not required to do this. Tracing a program is a different world compared to using the register keyword or not
Ilya
@Danya If not considering special cases, ok, I agree
Anonymous
Even if you need to trace a specific register, the register keyword is not related to the problem at hand
Ilya
Ok, dude. You just dont know what are you talking about
Anonymous
Ilya
Linux kernel modules are running in kernel space
Anonymous
Ok, dude. You just dont know what are you talking about
How is the register keyword use in not specific programming related to kernel development?
Anonymous
sure, so?
how does this relate to my knowledge in other languages?
Ilya
I wasnt correct. C++ programmers can write these modules, but not in C++
Ilya
That was the idea
Ilya
@rellc There are no non-specific applications, you are right
Anonymous
it's not that you can't, it just will be much harder then it should be, and makes 0 sense to even try
Anonymous
It's technically possible to use C++ for a module. But it will be a nightmare and you will need to perfectly replicate the C ABI
Ilya
Of course, you can write your own C++ compiler for linux kernel, or you can try to use LLVM (how it is with Rust)
Ilya
but for what?
Mar!o
How is the register keyword use in not specific programming related to kernel development?
The register keyword is ignored by the most compilers. The idea was that the variable is used very much (for example in a loop), so it should reside inside a register. But the compilers know register allocation better, so most of them ignore it. But if you declare a variable with the register keyword, you can no longer get an address to it because you cannot have an address to a register. register int x; int* y = &x; // won't work
Mar!o
Do you know that LLVM has a C++ compiler?..
Yeah and LLVM IS written in C++
Anonymous
but for what?
I don't know, you just said it's impossible as a fact. lol
Ilya
You are cling to words, guy
Janko Ⓥ
Yeah and LLVM IS written in C++
So is gcc, unfortunately :P
Anonymous
So is gcc, unfortunately :P
gcc is written in C
Anonymous
Though they have plans to rewrite in C++
Mar!o
Though they have plans to rewrite in C++
Yeah I think some parts already use some C++. And that's fine. C++ is a great language if you know how to use it
Janko Ⓥ
gcc is written in C
Lmao? No, look at it yourself
Anonymous
Lmao? No, look at it yourself
https://github.com/gcc-mirror/gcc/tree/master/gcc/c
Ilya
I think Janko told about g++
Anonymous
I think Janko told about g++
It's mainly written in C
Anonymous
https://github.com/gcc-mirror/gcc/tree/master/gcc/cp
Ilya
Oh, really. I didn/t know about the fact
Anonymous
https://github.com/gcc-mirror/gcc/tree/master/gcc/cp
According to filenames only c++20 features are coded in C++
Janko Ⓥ
https://github.com/gcc-mirror/gcc/tree/master/gcc/cp
I distrust that, I'm cloning the original repo right now. Will share results of wc -l from find
Anonymous
It's a daily mirror
Anonymous
The team behind GCC told officially that C++ is an admissible language as long as it is used in a sensible way. In the present though, C++ has not been used widely by those programmers
Anonymous
Outside libstdc++ you will hardly find C++
Janko Ⓥ
janko@laptop gcc $ find . -iname *.c | wc -l 63229 janko@laptop gcc $ find . -iname *.cpp | wc -l 245 Drat. Well, it's built as a C++ program by default since 2012 or so. It's nominally a C++ program.
Anonymous
Or a part of libstdc++
Janko Ⓥ
Irrelevant, I'd say? C++ features are used for the C compiler. Would you call Linux an assembly program since it contains a lot of assembly code? The same logic may apply here, C is auxiliary
Janko Ⓥ
How can you say that it's a C++ program nominally?
Because it's compiled as a C++ program
Anonymous
If a C program has a minimal part in C++ it's not a C++ program
Janko Ⓥ
That's why I stressed nominally
Anonymous
Because it's compiled as a C++ program
What do you mean? The build process is not done with a C++ compiler