dentry_path_raw not working C - c

So, I'm trying to compile this code that I have to try and "hide" a file (doing this for my security class) and I can't seem to get it working, it seems that linux/fs.h has removed/depreciated dentry_path_raw? Do you guys know how to fix this by any chance?
magic = dentry_path_raw(fp->f_dentry,filename,INTERNAL_BUFFER_LEN);
and it throws this error on build
error: implicit declaration of function ‘dentry_path_raw’

The error is because you are not including explicitly the header that declares the function and the compiler is 'including' implicitily for you and this throws a warning. You could try to add: #include <linux/proc_fs.h>
More, create_proc_read_entry is a deprecated function. Have a look here

Related

VSCode not importing functions from other files in C language

I am going through a C course and got to the point where we #include "myfile.h"
Good news : VSCode finds "myfile.h" and can pull variables from it, such as int myvar=10;
Bad News : VSCode does not seem to identify function definition in the "myfile.c", so extern in myfunction() is seen but not defined.
This results in the following
int i = myfunction();
Compilation Error: undefined reference to 'myfunction';
How can I get VSCode to recognize and use "myfile.c"?
Answer found in ::
undefined reference error in VScode
Basically, I had to compile all my files at once. This required me going into the tasks.json file and modifying it from ${file} to ${workspaceFolder}\*.c
This is better explained in ::
https://code.visualstudio.com/docs/cpp/config-linux

Undefined reference to the function 'check' (GCC compilation in MinGW)

I seem to be getting the rookie error where it says, undefined reference to 'check', as shown below:
This should not be a problem, as I have in fact made a check.h and included in hiker.c, as shown below:
Does anybody know the source of this problem? I have just started using MinGW(as I wanted to learn programming C on Windows).
Here is a picture of the main function. I can add the code too if necessary:
I guess that check function is implemented in a file check.c
You must link that file also, because of your check.h export the prototype to let the compiler know how the check function is structured, but the linker needs the check function code compiled and reachable.
What you need is to compile using a command like this:
gcc -Wall hiker.c check.c -o hiker.exe
Take also note that linker is giving you another error about WinMain#16
This means that you started a windows application project, I guess you must change your project to console project type.

lex prefix undefined symbol yyparse

I am including two diferent lex parsers in my C code so to include the second one defined a Prefix on it:
%option prefix="prep"
When I integrated this one in the global proyect It compiles without errors but on execution, If I try to call prepparse (formerly yyparse) I get this error:
undefined symbol: prepparse
I have tried including an external reference (not quite sure if this is correct):
extern int prepparse(void);
And defining it in the Lex header:
#define yyparse prepparse
But I still get the same error.
Any idea of what I am doing wrong?
I think I got it. I have found I omited one information that has proben important. As I only wanted to alter some tokens and not defining a full language (it is only preparsing) I dind't define a Yacc file, so I was not actually a parser but a Lexer what I had to call. So the command is not preparse but preplex.
I stil don't have it working but I guess it is another different issue.

Is it possible to modify compiler include path for Dymola?

This question is raised due to a situation that I encountered
Say I have these external files and some declarations or definitions in them:
foo1.h
extern void ext_func();
foo1.c
void ext_func(){
....
}
foo2.c
#include "foo1.h"
int Modelica_func(){
ext_func();
}
I defined ext_func() in foo1.c. Then, in foo1.h I declared it to be extern, because I want to use it in foo2.c. Modelica_func() is the function that I will be using in Modelica.
The compiler always throws out error LNK2019 to me complaining unresolved external symbol, I guess it's probably due to the reason that the header file cannot find it's matching c file. I am working in Dymola, and I've put all of these files in WorkingFolder/Sources/Include. But still I got the same error. I want others to see my code, so I cannot use static or dynamic library.
Greatly appreciated if anyone could help me a bit of this. THANKS!
You can find some details in Section 12.9.4 of the Modelica Specification.

zlib on z/OS USS

Im trying to compile z/lib on z/OS USS(thats right a mainframe). ive got gmake and the c89 compiler (which im assuming is c89 standards compliant) and USS is supposed to be POSIX compliant.
But zlib seems to be tripping up on
struct internal_state FAR *state; /* not visible by applications */
with the following error(s)
c89 -O3 -DUSE_MMAP -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_SOURCE -c -o example.o example.c
ERROR CCN3277 ./zlib.h:92 Syntax error: possible missing ';' or ','?
ERROR CCN3007 ./zlib.h:92 "struct internal_state" is undefined.
ERROR CCN3166 ./zlib.h:103 Definition of function FAR requires parentheses.
ERROR CCN3276 ./zlib.h:103 Syntax error: possible missing '{'?
ERROR CCN3273 ./zlib.h:124 Missing type in declaration of gz_header.
ERROR CCN3166 ./zlib.h:126 Definition of function gz_header requires parentheses.
ERROR CCN3276 ./zlib.h:126 Syntax error: possible missing '{'?
WARNING CCN3137 ./zlib.h:1346 Declaration must declare at least one declarator, tag, or the members of an enumeration.
ERROR CCN3275 ./zlib.h:1350 Unexpected text z encountered.
ERROR CCN3282 ./zlib.h:1350 The type of the parameters must be specified in a prototype.
ERROR CCN3275 ./example.c:95 Unexpected text file encountered.
ERROR CCN3045 ./example.c:95 Undeclared identifier gzFile.
ERROR CCN3046 ./example.c:96 Syntax error.
ERROR CCN3045 ./example.c:98 Undeclared identifier file.
ERROR CCN3019 ./example.c:523 Expecting an array or a pointer to object type.
ERROR CCN3280 ./example.c:527 Function argument assignment between types "const char*" and "int" is not allowed.
CCN0793(I) Compilation failed for file ./example.c. Object file not created.
FSUM3065 The COMPILE step ended with return code 12.
FSUM3017 Could not compile example.c. Correct the errors and try again.
gmake: *** [example.o] Error 3
when i progressively take out the FAR * (i think its a far pointer but im really not that sure) the errors go away. But as this is a library, im not sure what other artifacts are going to be produced by removing this.
has anybody got any ideas?
any old mainframe heads out there?
it turns out there is a previous version of zlib that compiles on USS, version 1.1.4 or close to that. Its a back level, but i presume this works because it is before the implementation of the FAR pointer in the latest code. So atm i think ive got it to work.
thanks for all your help.
Regards
Mark.
FAR is not a C89 keyword, it is a Microsoft/Intelism and is probably #defined somewhere. If not, you need to define it as nothing:
#define FAR
However, this will probably only fix one of many problems. I would guess that the library uses some form of conditional compilation to handle things like FAR pointers - you need to read the docs to find which configuration is most suitabkle for your platform.
I'd use xlc instead of c89 since xlc is your system default compiler but you'll still probably have issues. I'd subscribe to the MVS-OE email list, the people on it are quite helpful. The link to info about the list appears to be down now so send email to
LISTSERV#VM.MARIST.EDU
with the message: INFO MVS-OE
FWIW, IBM provides a prebuilt version of zlib that includes support for the compression hardware (so-called zEDC) available on recent-vintage mainframes. See zlib for zEnterprise Data Compression

Resources