dynamic semantic errors checking [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I read that dynamic semantic errors cannot be detected by the C compiler as semantic analysis phase catches only static semantic errors.
Then which component of C compiler does the checking of dynamic semantic errors?

which component of C compiler does the checking of dynamic semantic errors?
No phase. They are detected at runtime, if at all, by definition.
By dynamic semantic error, I mean accessing an index of array (out of bounds).
There is no such check in C.
I read somewhere that compiler generates code for checking dynamic semantic errors.
Not in C.
I am not sure what it meant.
Nothing in the case of C. Possibly you were reading about some other language. In any case the dynamic semantic check is still executed at runtime, not by any compiler phase.

As for my understanding the dynamic semantic errors can be discovered only during the runtime. C does not have any mechanisms for it, as C does not allow any dynamic semantics at all :) It is not an interpreted or JIT comiled language.
If you provide a real example of the dynamic semantic error in C, it will clarify what you actually mean

Related

implicit dynamic linking vs explicit dynamic linking - which is more effective? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
There are two ways to link a shared library .
one named implicit dynamic linking and one named explicit dynamic linking.
I have googled some doc not found docs tells the difference on efficiency of the two .
Take a linux .so file as example . my doubt is : the implicit linking compare with the explicit way , will the explicit way cause more IO or cpu or memory somehow ?
Wondering which way is more effective and why ?
thanks a lot !
From what I understand, implicit dynamic linking is the fact of saying that your program needs the library in order to run, by adding the library in the dependency section of your program. If the library isn't found at the start of the program, the program simply won't be executed.
Explicit dynamic linking is using a function like "LoadLibrary" (windows) or "dlopen" (Linux) in order to load a library at runtime. It's exactly what a plugin is, and how you can code it.
Now, doing an explicit dynamic linking is going to add work and complexity, and I don't see any reason for it to be more efficient than an implicit dynamic linking. You use explicit dynamic linking only when you cannot do otherwise, like loading a library depending on some runtime value.

What does a C #include statement do in a Fortran code? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
In the middle of a code there is a C language statement. I don't know why it is there and how the compiler does not give back an error. Is it for C binding? Does it mean that this module can be used by C program or vice versa?
USE LISTS
USE LINKEDLIST_ROUTINES
#include "macros.h"
IMPLICIT NONE
PRIVATE
It is not a C language statement, but a C preprocessor (cpp) statement.
Any text file can use the preprocessor, even Fortran source codes, but you must call the preprocessor before compiling.
Many Fortran compilers will call the preprocessor for you with flags -cpp or -fpp or similar. They might also call it for you if the file suffix starts with capital F.
What the #include "file" does is the same as what it does in C source files, it inserts the text from the file in that location.
There is also a standard Fortran (90+) statement include. It is similar, but happens after any eventual pre-processing has been done, see Includes revealing with Fortran preprocessor for more.

How do programmers make a programming language on top of C? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am interested in making my own programming language on top of C, but I have no
idea where to start.
So, I researched, this caught my attention:
A lot of languages are C-based.
Popular programming languages like C++ and Objective-C, and possibly C# and Java are all built on top of C. (Not to mention Python)
How did C++ and Objective-C creators managed to make a new language that is C based, but add object oriented programming concept added?
C based does not neccesarally mean that it's interoperable with c. It can just mean, that it uses the same paradigm or similar syntax like egyptian bracets.
Java is C based but also borrows from Smalltalk and it cannot run any of C code. C++ can call C functions because it's compiler produces the same binary code as C code. Once you have linked their binaries they become interoperable. Pythons implementation CPython does not produce any binaries first, it's an interpreted implementation, meaning it is run by an interpreter Programm which holds the whole parsed syntax tree in memory. And because the Interpreter is just a C programm itself, it can call other C functions. So there is no such thing like adding features in top of C. Those are different languages, with differen compilers/interpreters and grammatics which just borrow some of the grammatical rules from c.
The easiest way to start creating an own language, is by using a parser generator like antlr. And i would start creating an interpreter and not a binary compiler. Perhaps a compiler, which compiles to c. Knowledge about language grammatics is essential.

"Declaration Not allowed here" and "Constant Expression" Error in C [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I used Microsoft Visual Studio to write a C code in C++ project and It's working fine there when I convert the file extension from my.cpp to my.c and tried to run in via TurboC++ 3.0 then it gives me number of errors like "Constant Expression Required" and "Declaration is not allowed here".
I tried to run my code online compiler but its not giving me these error there.
Can anyone help me with this ?
I hope it's due to C99 mode but not confirmed.
TurboC++ 3.0 Supports C99 or not ?
Note: I can't share my code directly here due to project research work , If anyone want to have a look at my code I can send you via private message , Sorty for that
The error: Declaration Not allowed here is due to the mixed type declaration of variables and the error: Constant Expression required is because of the variable length arrays.
Mixed type variables and variable length arrays are are allowed in C99 and latter. Neither MSVC nor Turbo C++ supports C99.
I tried to run my code online compiler but its not giving me these error there.
This is because almost all new (and online) C compilers support C99.

hard to understand this macro [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
#define __HAVE_ARCH_STRCPY
What's the meaning of __HAVE_ARCH ? I'm not a native speaker and I fail to find the meaning of it by google...(maybe this question is quite silly)
By defining the __HAVE_ARCH_XXXX pre-processor tokens, it allows other locations in the OS kernel to test if the current hardware platform supports the strcpy, memset, etc. functionality. You'll notice that on some platforms, this token is defined, and then a basic implementation of these functions are defined as inline functions along with the token, since on those platforms, the functionality is not provided by some other kernel library or kernel code module. On other platforms, the functions are defined in some other code module, and may be simply declared as extern just after the pre-processor token.
Keep in mind that the kernel itself in Linux does not have access to the standard libc library, so these functions have to be defined separately from what you would typically use in a user-land application that is linked against libc. Thus it's important to define what standard functions are present, and which ones are not, as it may vary from platform-to-platform.
"This architecture has strcpy()".

Resources