seeing output of C code in Xcode on mac - c

I'm using Xcode to write C code. Firstly, it took me for ages to figure out that I need to go to Product->Edit Scheme->Select Executable in order to run C executables.
I have a lot of source files and each one has a main so is there any way to run C source files by just selecting them from left-hand pane and pressing Run? Is there a simpler workflow?

Add new target and select the source file which you need and assign to this target and run.

Related

Clion with more than 1 C file

So i have been using VSCode and back there I had only to make new file save as .C and when I pressed the "run" it automaticly created the "exe" file by themself.
This method is important to me because as I am on programming class, I have the A B C D E F ... exercise to run.
I heard Clion was one of the best tools out there for C, and i have a student acc so decided to try. But here when I create a new project it only lets me run the first file, tried to add a new source file but it fails.
Is there any solution ?
Thanks
CLion uses CMake as makefile generator. I think this question is about CMake "language" and not about CLion. With CMake you can create multiple executables but there is no automatic way to do it.
You can't have more than one source file if you want it to run independently in the same project. As you may know there should be only one main function where the program initiates.

Is it possible to view FASM preprocessor output?

I'm using fasm to compile a dll that uses macros shipped with fasm, i would like to see what the output is after the preprocessor stage but before the binary stage. Is there any way to see this? I would like to quickly see what is being generated to see if it's Worth getting rid of the dependency on the macro.
Fresh IDE has a feature "Unroll macro" - compile the source, position the caret on the row with the macro invocation and press Ctrl+U or select from the drop down menu "Unroll macro". The preprocessed code will be displayed on the scratch pad window.
If you want the whole preprocessed code at once - use the converting tools located in the FASM package, in the directory tools/ - you need to compile tools/%YOUR_OS%/prepsrc.asm.
But you should always remember, that the reverse side of having so powerful macro engine is that the complex macros are pretty hard to debug.
You could get it by prepsrc. You need to compile tools/%YOUR_OS%/prepsrc.asm by fasm.
fasm WIN32/PREPSRC.ASM
Next you need to get fas file. I do it by fasmw: Run -> Build symbols (for example let's call it file.fas).
Next:
prepsrc file.fas our_preprocessed_code.asm
our_preprocessed_code.asm will contain preprocessed souces.

PRO*C compile wrong comments

I've a strange behaviour on my pc when a I precompile a .pc source file. I use a command line instruction, like "proc wpd_ric_pla_02.pc wpd_ric_pla_02.c CODE=ANSI_C".
If I compile the very same source file on another machine, with the exact same version of proc (11.1.0.7.0), instead, I have no issue.
I attach an image showing some differences in the .c generated.
You can see on the left the correct .c and, on the right, the .c generated on my machine. SQL instructions are wrongly commented out.
Could someone please help me understand why this happens?
Thank you, Sebastian.
It may have something to do with the file being copied from one machine to the other. But this is only a wild guess.
Maybe the wrong file have some non-visible characters that are messing the compiler.
You can check it by doing a hexdump -c wpd_ric_pla_02.pc if you are in Linux.
If you are using Windows I suggest you use Notepad++ View / Show Symbol / Show All Characters function.
If that doesn't work, try isolting the problem in a single query.

NASM setting in Vistual Studio13

I am creating a library, which require some assembly level code.
I am using using NASM to write and integrate my .asm file.
Now the problem is, I already have a project created in VS13. Now I want to add and integrate an assembly level code to my project.
I have already added a .asm file in my source directory, but when I am trying to run my test case, the compiler is unable to find my assembly code.
I want to know how can I link my .asm file with my .c file.
Structure of my project:
->Project1(Generates a Library)
--->Source
----->File1.c
----->File2.c
----->nasm.asm
->Project2 (Test case to use the library and generate .exe)
-->Source
---->main.c
Now, nasm.asm binaries should get attached with the .lib generated by project1
and Project2 should able to access project1.lib
Apologize if question is bit unclear, its a bit complex for me to make it clear in written. Please let me know if you want any clarification or extra information.
Thanks a lot
For each of you assembly files:
Right click it in the Solution Explorer and choose Properties
Make sure the selected Configuration is either All Configurations or the configuration you are using (this bites me every time!)
In the Configuration Properties>General change the Item type to Custom Build Tool
From the Configuration Properties>Custom Build Tool>General set the following items:
Command Line. Use this as an example: nasm -fwin32 "%(FullPath)" -o %(Filename).obj
Outputs. This is necessary, VS check for this files. I usually use %(Filename).obj.
Link Objects. Yes. If you name your output files with obj extension they are automatically included in the link phase.
To check that you set everything right, select your assembly file, right click and choose Compile.

CodeBlocks MinGW on XP noob. Is it possible to overwrite the same exe every time I compile? Further explanation inside

I have looked through both the CodeBlocks and MinGW FAQ and wiki to no avail. As stated above I am a noob.
I want CodeBlocks to act like a Unix compiler in that it overwrites a single output file every time it compiles unless told to do otherwise.
In Unix:
[cc example.c] -> [a.out], [cc example2.c] -> [a.out]. If I want to save the output file from being overwritten i just [cc -o newname example3.c] - [newname.out].
If this is possible with CodeBlocks/MinGW on XP I'd like to know how to do it. If not I would appreciate recommendations for another GUI compiler/IDE that could. Any help is appreciated. Thank you.
I want CodeBlocks to act like a Unix
compiler in that it overwrites..
First of all, C::B isn't a compiler -- it's an IDE. Saying you want C::B to act like a compiler makes no more sense then saying you want vim, emacs, or visual studio to 'act' like a compiler.
Second, you change the name of the final executable by right-clicking a project in your workspace. Goto properties->Build targets tab->select which build target you want to change. On the right side of this you'll see Output filename. Enter the executable filename the linker should output here. Alternatively, you can just navigate to the location of your existing executable and just rename it to something else.
And thirdly, chances are you're not even going to be checking back on this site so I'm probably just wasting my time giving an answer to your post.

Resources