Cannot compile C program in Visual studio code - c

I am getting this results in the terminal.
gcc.exe: error in visual studio code.
How to fix this?
I was working well until now, don't know what happened.

If you want to add spaces to the name of your C/C++ files, you will then need to let the compiler know that this is a single file, this can be achived by using quotation marks around the file name:
gcc "If condition.c"
That said, it's not the best idea to have C/C++ files with spaces, you shouldn't do it.
Suggestion: rename If condition.c as If-condition.c or If_condition.c

Related

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.

Compilation error on include with ljpeg library in C

I have a project for college, where i need to use libjpeg (C language), to complete 2 codes the teacher gave to us. It's a about transforming a pic into ASCII symbols (like the ASCII draws, you know)
We have a code for reading a jpg and a code for writing a jpg.
The problem is i had to install the libjpeg, i THINK the installation went well but i'm not sure so i have 2 questions
How can i verify libjpeg is correctly installed ? i didn't link it to gcc so i have to use the option for saying to gcc where is jpeg-6b (the folder which contains ljpeg) so i tried this :
Typing "gcc -L/jpeg-6b" the folder is jpeg-6b and it's right on the location where i do the command. i only get an error message about the fact the input is empty (normal ok), i think if the lib was not correctly installed, i should get an error for saying me i can't use the libjpeg version, right ?
In the 2 codes i said the teacher gave to us, she puts #include <libjpeg> on the beginning of it. But i saw on the internet that people use #include <jpeglib.h>, but both of them DON'T work and i get a message telling me :
test.c:1:21: fatal error: jpeglib.h: no such file or directory
#include <jpeglib.h>
is my include bad? or is the libjpeg bad installed ? (i read the doc and i did ./configure then make like it's said)
Just as you add -L/jpeg-6b you need -I/jpeg-6b/path/to/jpeg/headers too. I would recommend a Makefile to automate this.

Error in Visual Studio while debugging "parameter 'basepath' cannot have zero length"

I am facing this error while trying to debug C code in Visual Studio 2010. When searched in google all i could find something related is as below
http://connect.microsoft.com/VisualStudio/feedback/details/615793/badly-formed-debugger-command-causes-error-parameter-basepath-cannot-have-zero-length.
Any suggestions to overcome this is really appreciated . Thanks
Same problem, I was building a function library to load on demand, but got this message. It is a matter of don't quote the VSDebugger options.
Remove the double quotes from
the full path of the executable
the command arguments
the working directory
embedded spaces can be passed to the command line by single quotes, if really required.
I had the same error message with only the name of the executable in the command (so no full path). It used to work pefectly, but suddenly it didn't. I checked the path variable and somehow there were two consecutive ';' in there. I fixed that and the problem disappeared.
In my case the command line did not have .exe extension at the end (Properties->ConfigurationProperties->Debugging->Command). Adding the extension fixed the problem.
For me "Parameter "basePath" cannot have zero length" was caused when I set my configuration properties->debugging->command to "regsvr32.exe $(TargetPath)" to debug my project registration. I fixed this by setting the command to "regsvr32.exe" and command arguments to "$(TargetPath)"
If you set up a makefile project (I guess it's the case), be sure that the file you put in Configuration Properties -> Debugging -> Command exists.
(and I think it doesn't accept batch files, but I'm not 100% sure)
check your path in: Configuration Properties -> Debugging -> Working Directory.
check that this path is a valid path in your machine.
I've solved this problem with setting value of Properties->Debugging->Command to another, and after it set back to my default.
Also make sure Visual Studio is running "As Administrator". This fix it for me.

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.

Does the Visual Studio C compiler have an equivalent to GCC's -M?

I would like to automatically generate a Makefile dependency list, but I am using Visual Studio 2005. If I were using GCC, I could pass -M (or one of the many variants) to create this dependency list.
Looking through the command line options to cl.exe, I don't see anything obvious. I can handle tweaking the output with post-processing, but the closer the better.
In the cl.exe of Visual Studio 2005 at least, there is the option /showIncludes.
I had to deal with that exact problem. We wanted to add a script that replaces the -M option. Here's how I did it:
find a source preprocessor ( and the include paths & defines you need )
run it on the file you need, and it should produce a preprocessed version.
most preprocessors have a switch that enables extra info ( such as the file where some code snippet came from )
write a simple script to extract all the header names
create a set out of them, so that you filter out duplicates.
It's how I've done it, and it worked. Good luck!
The compiler stores dependencies in the intermediate .idb file. You might be able to parse it from there.
See https://msdn.microsoft.com/en-us/library/kfz8ad09.aspx
You can find all included files prefixed with "/mr/inversedeps/" or "/ipm/header/" in there, it seems.
I think you should also find dependencies in other intermediate files, e.g. "CL.read.1.tlog".
Not directly with cl.exe, but with this wrapper you can achieve what you're looking for:
http://msdn.microsoft.com/en-us/library/y209k0z6.aspx
We had the exact same issue with Fortran, and ended up having to write our own mini-compiler to scan the source code and traverse all the #includes.

Resources