replacing stdio.h

replacing stdio.h

If a programmer removes stdio.h in source code that he compiles with icc, then how is

FILE *fid

fprintfid,"FREQ = ");

handled? we obviuosly want to print this into a file not to the screen, but by removing

stdio.h we cannot do it.

Again, theis works fine in gcc, not so fine in icc.

Any help appreciated.

Newport_j

9 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de Georg Zitzlsberger (Intel)

Hello,

"FILE" is not a standard type. Hence a compiler following strict standards will fail here with an unknown identifier message. "stdio.h" is the one aliasing type "FILE" to some base type or struct of base types; only when this is done the compiler can understand the "FILE" identifier.
I know that in some cases (like yours) GCC tolerates omitting this header but that's more for convenience and does not generally work for all types/functions defined in "stdio.h" AFAIK.

The correct way is to always include headers whose defined functionality you're using. In your case: "stdio.h".

Best regards,

Georg Zitzlsberger

I understand that. I am using icc and it simply does not like working with the icc compiler. So if I am to use the structure that I outlined at the beginning of this thread, then how do I print output to a file? Remember, gcc and stdio.h ok, icc and stdio.h not ok.

Any help appreciated.

Newport_j

I made a typo here. It is icc and stdio.h that do not work together, obviously not icc and icc.

What doI do when I need to print to a file and I use the icc compiler?

Newport_j

imagem de Georg Zitzlsberger (Intel)

Hello,

I'm a bit confused now. So far I've never heard of any problems regarding our compiler and "stdio.h" from the system.

Let's start with an example:

#include 
int main(int argc, char **argv)

{

    FILE *fh;
    fh = fopen("test.log", "w");

    fprintf(fh, "SUCCESSn");

    fclose(fh);
    return 0;

}

If you do

$ icc test.c -o test

...it should have compiled test correctly. You seem to see an error message instead, don't you? What is it?

Please also compile with "-H" option and look whether "stdio.h" exists. I get something like this:
$ icc test.c -o test -H 2>&1 | grep stdio.h
. /usr/include/stdio.h

What's your output and does this file exist? Is it readable for you, too? (e.g. cat /usr/include/stdio.h)

Edit: In case "stdio.h" is missing on your system, did you install the libc6-dev (or similar) package?

Thank you & best regards,

Georg Zitzlsberger

The stdio.h file is there and it is readable. But, when I try to compile the code you wrote this is what I get:

/usr/include/libio.h(53) catastrophic error: cannot open source file "stdarg.h"
# include
^

compilation aborted for test2.c (code 4)

my file name is test2.c. Now, if you look at some of my previous threads you can see that I thought the way to correct this was delete

#include

If there is a better way, I would like to know?

Any help appreciated.

Newport_j

imagem de Georg Zitzlsberger (Intel)

Hello,

could you send me output from:

$ icc test.c -o test -H
and
$ gcc test.c -o test -H

plus
$ dpkg -S stdarg.h
and
$ gcc -v
and
$ gcc -dM -E -

Please also check that all the files printed from "dpkg -S stdarg.h" are actually on your system and accessible!

Looking at your other threads I assume you're using Ubuntu* 11.10 (oneiric) and Intel Composer XE 2011 Update 9 (12.1.3). Please correct me if I'm wrong.

There is no reasonable way not to use "stdio.h" in your case. Such basic things should always work and if not there's high likely a problem in your build environment that should get solved. Otherwise you'll run from one problem into another.

Thank you and best regards,

Georg Zitzlsberger

test.cerr.txttest2.shout.txtI am using ubuntu 11.04.I think that I know what is wrong. I still have on my desktop Cilk Arts Cilk++. If you look at my path in one of the attached files you will see

/home/james/desktop/cilk/bin/

Which takes you to the Cilk Arts installation. Can I remove the Cilk Arts install by deleting the cilk directory? Are there sytem files that I must chnage.

Do I neeed to reinstall Intel Cilk++?

If you lood at my path before and after

source compilervars.sh

you will notice that path sections are added to the front and the back of my original path. Is this normal?

I am attaching all relevant files.

Any help appreciated.

newport_j

imagem de Georg Zitzlsberger (Intel)

Hello,

thank you for the comprehensive information you provided! Unfortunately not all attachments can be opened.

Anyways, I think I've an idea:
You were building an own GCC version which has been configured for installation prefix "/home/build/32/local/cilk" but in the end you're using GCC from "/home/james/Desktop/cilk". If you have moved (or copied & removed) the location there might be some pointers to the old location not being updated. Our compiler depends on those to find the correct paths for libraries & include files.

Could you please rebuild with using the final installation prefix without moving/copying anything around?

To make sure that a setup like yours works with our compiler I've also compiled my own GCC compiler (same version: 4.2.4). Only "gcc" had to be in $PATH so our compiler can find the correct libraries & header files automatically.

Best regards,

Georg Zitzlsberger

Faça login para deixar um comentário.