assembly-c from windows 10 command prompt [duplicate] - c

This question already has answers here:
How do you get assembler output from C/C++ source in GCC?
(17 answers)
How to remove "noise" from GCC/clang assembly output?
(3 answers)
Closed 4 years ago.
I'm trying learning assembly language and i need to know how to read the assembly varsion of a c program from the windows 10 command prompt.
I've tried using C:\users\prete\Desktop\booksrc$ gcc -g firstprog.c but it doesn't work
please help me
thank you!

I am not sure about windows, but as far as I know, the assembly output is gained by the -S option for gcc.
Try gcc -S firstprog.c
The output will be firstprog.s in AT&T syntax. If you want it in the intel syntax (might be rather helpful if you use NASM/MASM/YASM and such for assembling), try:
gcc -S -masm=intel firstprog.c

Related

What are .o files and to open them on windows? [duplicate]

This question already has answers here:
What's an object file in C?
(5 answers)
Closed 3 years ago.
I'm a beginner in programming, I wonder what is inside the .o files and want to see it, but can't open the files in windows because they give some output with unrecognized symbols. Please suggest something !
They are object files, produced by the compiler, which the linker will combine into an executable.
They are not intended to be human readable.

What does gcc -E mean? [duplicate]

This question already has answers here:
Preprocessor output
(6 answers)
Closed 5 years ago.
I came across this option of -E while navigating and searching for where the file descriptors of stdio.h is stored in the machine? But I am not sure what exactly this command gcc -E do? Can it be used to view the file descriptor of the stdio.h fie stored in /usr/include/ directory?
It tells GCC to stop after the preprocessing stage. Details in the link.
https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options
It will show the output the compiler produces after expanding all macros.

linker error undefined symbol _log10f

I am using log10f function of math.h header file and I need to calculate log value in float that's why I use the above function
I am just posting the sample code instead of the actual code due to confidential information
#include<stdio.h>
#include<math.h>
void main(){
printf(" --->>> %f \n", log10f(4) - log10f(3));
}
Some how I am able to run that code in linux using gcc compiler with following command and it compiled properly and running properly
gcc Demo.c -lm -o Demo
./Demo
But I have to run the project on the windows too and I am using window 7 and turbo c but using tc my program compiled properly but at run time it showing me a LINKER ERROR UNDEFINED SYMBOL _LOG10F
Anyone have any Idea that how can I resolve this issue on Tc at windows.
Suggestions are most welcome thanks a lot in advance.
log10f was added to the C language 16 years ago. You are using a a compiler which is 25 years old, so it won't work.
A work-around might be to use log10 instead, which was available in the C90 standard. It uses double instead of float.

how to gdb a program containing parameters [duplicate]

This question already has answers here:
How to load program reading stdin and taking parameters in gdb?
(6 answers)
How do I pass a command line argument while starting up GDB in Linux? [duplicate]
(4 answers)
Closed 9 years ago.
often i see some gdb guide using examples without parameters. But in parctice, i need to gdb debug a programe with parameters.
this program is run as "./voronoi -t outputfile", -t is programme voronoi itself parameter, is input, and outputfile is outputfile. but when i using "gdb ./voronoi -t outputfile", it will tell me some error, but when using no gdb debug, run "./voronoi -t outputfile" is OK.
How make it both can gdb debugging and aslo with parameters? How to set the parameters?
You may want to take a look at the run and start commands of gdb—you can pass them the commandline parameters just like you are used to at the shell prompt:
% gdb my_program
[...]
start par1 par2 par3 ...
$ gdb program
break linenumber|functionName
run [parameters]
if your system is windows,you can do this:
1.gdb your_program
2.set args para1 para2 para3...

Is there something like IDLE (python) for C? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is there an interpreter for C?
I want to practice C a bit and I would like to have something that allows to write and test C code quickly. I want to have an interpreter with UI where I can write my code and execute it.
Are there any good solutions for that?
The closest solution to what you are looking for seems to be the C shell (CSH) or C Scripting Language (CSL).
Alternatively, have an editor open where you will write your C sample, then have console window where you will execute your favourite C compiler. The idea is to have simple workflow like this:
$ gvim test.c
$ gcc test.c
$ ./a.out
Don't forget, C is not a scripting language.
However, you may find JIT compiler for C, C++, and the likes discussion helpful.
Though "interpreters" per se don't exist (or not practically), I'd advise on using a modern IDE. Eclipse + CDT allows you to have "on the fly compilation", just like in java. Your project is ready to run whenever you are, with reduced latency due to compilation (if you have a decent computer).
For other answers, I advise on NOT using directly gcc test.c. Use a makefile or use at least gcc -Wall -g -o myapp test.c top have additional information during compilation (useful as C has many more pitfalls than python). Please note as well that testis astandard program and that . might not be in your PATH : myapp is a better name than test ;-)
There is Cling. Never used it, so I can't really tell you more, but it looks like what you are looking for.
You might also find other lead in this question: Is there an interpreter for C?
you can take a look at : http://codepad.org/
or the easy way is to create a sh script like :
vim $1 ; gcc $1 ; ./a.out
You can't interpret C++ code as far as I know...
What you could do (and what I do when I quickly need to write some simple things ) is set up a simple make file and open a new file with some simple text editor like Kate that has a console plugin. Then you can write some code and type "make" to see the result of your code in the konsole / whichever shell you are using

Resources