fopen64/ fseeko64 and c++ 11 [closed] - c++

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 7 years ago.
Improve this question
Im writing a code in c++ with codeblocks. I included the flag : " get g++ follow c++ 11.." In the compiler settings to use chrono class, but after i included this flag i couldent compile the program because suddenly the function fopen64 "was not declared in the scope". Just so you know- i can compile the program without the flag.
How can i use both fopen64 and chrono class? Is this possible? And if not, is there other precise time measurement class so i can use to mesure microseconds?
Thanks!

The fopen64() function is from the Linux Large File Support library. It’s just a version of fopen() that supports files larger than 2Gbi. On a modern system, you can use the standard library function, fopen(). On Posix, you can use fseeko() and ftello() and on Windows, _fseeki64() and _ftelli64(). That said, defining _LARGEFILE_SOURCE might work on your compiler.

Related

How do I tell CMake to link the C standard library, not the C++ one? [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 9 months ago.
Improve this question
I have a simple C++ file, but I do not want to use the C++ standard library, just the C one.
Can this be done using CMake? Basically disabling access to the c++ headers, and only allowing linking to the C standard.
You can use target_compile_options(yourprog PRIVATE -nostdinc++) for clang and GCC based toolchains and /X with the path to its STL headers with msvc

Prettify compiling C++ from Command Line [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 4 years ago.
Improve this question
I'm playing with compiling C++ from native Windows CMD via VS 2017 compiler (vsvarsall.bat setup).
Is there any way to reduce the output of cl command, like Microsoft rigths for compiler and linker?
Also, offtop question: is it possible to compile code with UNICODE or ANSI strings (like I'm able to build from Visual Studio IDE), or am I gotta use manual #defines?
For your first question, see the /nologo compiler flag.
I'd guess the second is why people are voting to close--there's quite a variety of ways to deal with ANSI/Unicode strings, and without quite a bit more definition of what you really want, chances are pretty poor that anybody can give a meaningful answer.

How to run a C script code in a C++ program [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 5 years ago.
Improve this question
I would like to run a what I called "script C code" from string in my C++ program, for exemple :
int main(){
// my string (from a file): printf("Hello, Stackoverflow!")
RunScript(MyStringScript);
return 0;
}
I could use clang or other, but I have no idea how to do that...
PS: The goal is not to make a C interpreter, no, just run a C code to broaden my program.
The best way for reaching your goal, is to use a C interpreter library.
For example you can use this one: https://github.com/jpoirier/picoc
You could also do it with libjit. Because you are then running the system compiler, any ISO C/C++ code can be compiled (picoc is not fully ISO C complete)
Obligatory disclaimer: Running user supplied code at runtime is very dangerous unless it is properly sandboxed. Maybe consider doing it another way.

Programatically creating and compiling from a program in 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
Let's say we've got a first program called Program1.exe which contains the necessary information to create and compile another application called Program2.exe. Actually it could also load that information from a txt file or whatever.
Googling, I've found that this is "easy" to do in C#, using Visual Studio:
How to programatically build and compile another c# project from the current project
Programmatically Invoke the C# Compiler
The problem is that I'm not using (and can't use) C#, but C++. Summing it up, my question is if that I can do this same thing using C++.
I would prefer to do it without additional libraries, but if that's not possible, or if it's too hard to do, you can also recommend any library allowing it.
I think you'll probably have noticed it, but my goal is to use it under Windows so I don't care if it's not portable.
Thanks everybody.
It's trivial (if maybe a bit odd) for a C++ program to compile and run another based on code stored in a text file. Debugging that other program, however, isn't.

How to output to console window without iostream in 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'm a beginner C++ programmer.I would like to know that Is it possible to output to console windows without using iostream header file?
the answer of the question is actually Yes ! but How?
You can always delve down to the C library level, using e.g. printf.
If you don't want to use the standard library at all then you have to use platform-specific functionality. In Windows there are many layers here, much like the C++ versus C layers in the standard library. The highest Windows API layer is the WriteFile function, and below that, WriteConsole, then perhaps WriteConsoleOutput, so on, check it out.
Note that there are at least two open source projects to provide more reasonable console functionality in Windows, namely Console2 at SourceForge and mintty at Google Code.