windres syntax error

This is a discussion on windres syntax error within the C Programming forums, part of the General Programming Boards category; Hello everyone, I am programming in MinGW and have run into a problem trying to compile a resource (.rc) file ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Location
    hellertown, pennsylvania
    Posts
    24

    windres syntax error

    Hello everyone,

    I am programming in MinGW and have run into a problem trying to compile a resource (.rc) file using Windres.exe. I have downloaded the most current version of MinGW (as of 12/12/2011). When I use the command

    windres -O coff -i about1.rc -o about1.res

    Windres hurls back perhaps 100 lines that read "warning: null character(s) ignored". Just before terminating, Windres also states" "About1.rc:1:syntax error".

    There are no null characters in the resource file. Moreover, the first line is nothing more than a simple #include "dlgresource.h" statement.
    To further confuse things, when I use MSFT's rc.exe to compile exactly the same resource file, the compilation proceeds smoothly and the resulting .res file links correctly with the program's .obj file and runs as planned.

    Does anyone have any idea what might be going on?

    Thanks,
    Mark Allyn

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Yeah... use RC... Problem solved.

    It sounds like something is wonky with WindRes...
    Are your .rc files in unicode by any chance?

  3. #3
    Registered User
    Join Date
    Apr 2010
    Location
    hellertown, pennsylvania
    Posts
    24
    Hi CommonTater,

    Thanks for your reply. No, the file is not in UNICODE. Straight vanilla ascii.

    Mark

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by allynm View Post
    Hi CommonTater,

    Thanks for your reply. No, the file is not in UNICODE. Straight vanilla ascii.

    Mark
    Ok, without looking.... what's the minimum Windres command you can use?

  5. #5
    Registered User
    Join Date
    Apr 2010
    Location
    hellertown, pennsylvania
    Posts
    24
    Hello CommontaterL:

    The minimum command Windres excepts without complaint is:

    windres -v

    In which case, windres responds with:

    Using 'C:\MinGW\bin\gcc -E -xc -DRC_INVOKED -'

    What to make of this?

    Thanks,
    Mark

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ok... I just took a really quick look through the WindRes options.

    Have you tried... windres <filename> .... as in... windres about1

  7. #7
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    OP, he was right the first time. You don't get flooded by null characters warnings if you don't have a flood of them in your file.
    The file may only contain ASCII text, but it has been saved as a unicode file.
    Winres can't handle them, hence all the warnings.
    RC can handle them, hence why it works fine.
    Open it in notepad, save as, make sure the Encoding box at the bottom is set to ANSI and save.

  8. #8
    Registered User
    Join Date
    Apr 2010
    Location
    hellertown, pennsylvania
    Posts
    24
    Hi CommonTater and adeyblue,

    BRILLIANT! I did as adeyblue suggested and saved the .rc file as ANSI and windres was happy and the whole thing worked perfectly.

    I omitted in my earlier posts that a few days ago this and other .rc files I had accumulated were compiling fine with windres. Suddenly, nothing was working. I can't reconstruct now why I would have saved them initially in ANSI so they ran and then somehow later started saving them as Unicode...but I must have done so.

    I am feeling a whole lot better now...

    Thanks again,
    Mark Allyn

  9. #9
    Registered User
    Join Date
    Apr 2010
    Location
    hellertown, pennsylvania
    Posts
    24
    Hi again to CommonTater and adeyblue,

    A last observation on this business of Unicode and ANSI. I scoured the Binutils documentation on Windres and there is nothing in it that I could find that identifies this Unicode/ANSI incompatibility. I'm not so sure about MSFT's RC documentation, but it must create a problem for many folks. I couldn't see anything on the Internet either. Am I wrong?

    Mark

  10. #10
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by allynm View Post
    Hi CommonTater and adeyblue,

    BRILLIANT! I did as adeyblue suggested and saved the .rc file as ANSI and windres was happy and the whole thing worked perfectly.

    I omitted in my earlier posts that a few days ago this and other .rc files I had accumulated were compiling fine with windres. Suddenly, nothing was working. I can't reconstruct now why I would have saved them initially in ANSI so they ran and then somehow later started saving them as Unicode...but I must have done so.

    I am feeling a whole lot better now...

    Thanks again,
    Mark Allyn
    Good stuff... what editor are you writing .rc files with? You may want to check it's default settings to be sure they haven't been changed somehow... notepad, for example, remembers your last setting...

  11. #11
    Registered User
    Join Date
    Apr 2010
    Location
    hellertown, pennsylvania
    Posts
    24
    Hello CommonTater,

    When I use an editor rather than just sticking the script into a txt file using Notepad, I have used mainly ResourceBuilder. In the present instance, I cannot recall whether I originally generated the script using ResourceBuilder or just created the file using notepad. I wish I could remember. Its possible I did a bit of both: Started with the script generated by ResourceBuilder and then later edited it with Notepad. What I don't know--maybe you do--is if the original script saved using ResourceBuilder is saved as a Unicode file will Notepad later automatically save it as a Unicode file?

    My hunch is that ResourceBuilder is geared to MSFT .rc files and if so probably requires to override the Unicode with an ANSI switch. I'll have to check. Thanks for your help on this. It was driving me crazy.

    Regards,
    Mark

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Here's the rub... with so much being made of "internationalization" (multi-language user interfaces) you almost have to do everything in unicode these days, so it can be translated into other lanugages. I haven't written a plain ansi program in *years* because of this. So if WindRes is balking at unicode input files, I'm thinking that's your real problem...

    Also if you look at the resources for any version of windows since Win2000 they are internally stored as unicode, because Windows itself is internally driven by utf16le unicode. Even the ANSI apis are internally converted to utf16le. (The knit picking idiots on this forum will now line up to contradict me, of course, but it's right there on MSDN if you do a little reading.)

    I haven't used ResourceBuilder...
    But when I was making my last abortive attempt at C++ I did use ResEdit, which is very nice and it's free, and yes it will read and write unicode resource files in several different formats. Given that ResourceBuilder talks about updating resources in coff and pe files, it should imagine it has about the same capabilities. Check the help files...

    Your source doesn't absolutely need to be unicode, it's just easier if it is... but all your strings should be WCHAR not CHAR... and you should be working with the unicode APIs when you program so that it's possible to translate your programs to other languages... so maybe it's time to move it up a knotch or two... with newer versions of your compiler suite...

    Internationalization for Windows Applications
    Last edited by CommonTater; 12-14-2011 at 03:50 PM.

  13. #13
    Registered User
    Join Date
    Apr 2010
    Location
    hellertown, pennsylvania
    Posts
    24
    Good evening, CommonTater,

    I thought I had replied to your last comment earlier, but it appears that my response didn't make the deadline. So, I will be brief.

    I completely agree with your advice regarding Unicode and WCHAR. Ambitious developers should certainly follow your precepts.

    Resource Builder (V3) only creates Unicode files, no ANSI. So, it doesn't marry well with windres.

    On the other hand, ResEdit DOES generate ANSI files and this would make it a better match.

    All of this assumes that one prefers to stay within MinGW toolset and not wander off into "straight" MSFT.

    Thanks for your very thoughtful correspondence.

    Regards,
    Mark Allyn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 11-30-2011, 10:55 AM
  2. Error "in function 'main' syntax error before 'int' Help Please
    By blackhat11907 in forum C Programming
    Replies: 5
    Last Post: 08-20-2011, 07:05 PM
  3. error C2143: syntax error : missing ')' before ';'
    By steve1_rm in forum C Programming
    Replies: 4
    Last Post: 05-14-2008, 11:06 AM
  4. GCC compiler giving syntax error before 'double' error
    By dragonmint in forum Linux Programming
    Replies: 4
    Last Post: 06-02-2007, 05:38 PM
  5. windres error with RCDATA Resource
    By dit6a9 in forum Windows Programming
    Replies: 1
    Last Post: 08-01-2004, 04:09 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21