Bug 186069 - C/C++ Build Settings: Defined symbols stripping quotes during compile
Summary: C/C++ Build Settings: Defined symbols stripping quotes during compile
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build-managed (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL: http://www.redhat.com/docs/manuals/en...
Whiteboard:
Keywords:
: 282845 (view as bug list)
Depends on:
Blocks: 357048
  Show dependency tree
 
Reported: 2007-05-08 23:50 EDT by Gregory Czajkowski CLA
Modified: 2020-09-04 15:26 EDT (History)
5 users (show)

See Also:


Attachments
Patch to escape symbol definitions properly (3.75 KB, patch)
2009-04-02 04:25 EDT, Dmitry Kozlov CLA
no flags Details | Diff
Regenerated patch (1.86 KB, patch)
2009-05-29 03:23 EDT, Dmitry Kozlov CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gregory Czajkowski CLA 2007-05-08 23:50:14 EDT
Build ID: M7 I20070503-1400 
CDT ID: RC0 200705021527

Steps To Reproduce:
1.Project Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Compiler->Preprocessor->Add 
"ulong=unsigned long" or 'ulong=unsigned long' with the quotes. 
It looks correct in the dialog when it's added.

2."Build Selected File(s)" within the project on any file.

The resultant compile is:
"""
Rebuilding selected file(s)

**** Internal Builder is used for build               ****
g++ -Dulong=unsigned long -Dulong=unsigned long
""

The spec states that quotes should be preserved
http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/cpp/invocation.html

++G

PS. I know that -Dulong=unsigned is ~equivalent, was just using it as an example :)
Comment 1 Dmitry Kozlov CLA 2009-04-02 04:24:05 EDT
This bug is related with two other existing bugs: 236227 and 259781. 
I think this patch will help.
Comment 2 Dmitry Kozlov CLA 2009-04-02 04:25:29 EDT
Created attachment 130657 [details]
Patch to escape symbol definitions properly
Comment 3 Andrew Gvozdev CLA 2009-05-01 23:24:44 EDT
There is a workaround - you can wrap it in second set of quotes. Only one set gets stripped:
> 'ulong="unsigned long"'
or even
> ulong='"unsigned long"'
Comment 4 Chris Recoskie CLA 2009-05-28 15:44:47 EDT
This patch does not apply cleanly.  Can you please regenerate it?
Comment 5 Dmitry Kozlov CLA 2009-05-29 03:23:35 EDT
Created attachment 137607 [details]
Regenerated patch

I have regenerated patch without any changelogs etc. Just for source file. It is diff from CDT 5.0.1 generated by svn. If it doesn't apply, please let me know more details on what problem is.
Comment 6 Vladimir Prus CLA 2009-06-17 06:13:29 EDT
I can confirm this bug to be present in CDT6.0RC2. Note that it's internal builder bug, and the bug with generated makefiles is different. Dmitry's patch only addresses generated makefile -- shall I open a new bug to track that, or shall I attach 6.0 patch for generated makefiles here?
Comment 7 Andrew Gvozdev CLA 2009-07-08 09:58:11 EDT
*** Bug 282845 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Gvozdev CLA 2009-07-09 18:26:28 EDT
(In reply to comment #6)
> I can confirm this bug to be present in CDT6.0RC2. Note that it's internal
> builder bug, and the bug with generated makefiles is different. Dmitry's patch
> only addresses generated makefile -- shall I open a new bug to track that,

Please, open a new bug for the external builder problem if it is a different issue. Lets continue there.

> or shall I attach 6.0 patch for generated makefiles here?

I can apply the patch on the HEAD just fine. What I wanted to ask if you guys could provide unit test cases for these changes? There is a bunch of test cases in org.eclipse.cdt.managedbuilder.core.tests. I think you could take a look for example at BuildSystem40Tests or ManagedBuildMacrosTests or another one which suits better and add tests covering your changes? Why don't you attach test case patch to the new task?
Comment 9 Mike CLA 2010-03-10 16:03:36 EST
Has this been repaired ? I'm using 

SUSE Linux kernel 2.6.16.60-0.21-smp (SGI x86)
Eclipse 3.5.2R35x_v2010021
Intel's icc/icpc V11.1 compiler and their Eclipse integration which uses 

CDT 
Version 6.0.201002161416
Build id : 201002161416

I'm encountering this same bug. The workaround doesn't work in all cases. i.e. add a symbol

CURRDIR value "${CWD}"

this returns a compiler command line :

Invoking: Intel Intel(R) 64 C++ Compiler 
icpc -D"CURRDIR="/export/home/0094750/workspace/HelpMe/Release" ....

sticks an extra double quote after the -D

--------------------------

using '"${CWD}"' as the suggested workaround results in :

icpc -D"CURRDIR='"/export/home/0094750/workspace/HelpMe/Release"'" 

even worse.

--------------------------

using '${CWD}' results in :

icpc -D"CURRDIR='/export/home/0094750/workspace/HelpMe/Release'"

no better.

--------------------------

using : '"${CWD}/mydir"'

icpc -D"CURRDIR='"/export/home/0094750/workspace/HelpMe/Release/mydir"'" 

--------------------------

using : "/mydir/subdir1"

Invoking: Intel Intel(R) 64 C++ Compiler 
icpc -DCURRDIR="/mydir/subdir1" -MMD -MP -MF"src/HelpMe.d" -MT"src/HelpMe.d" -c -o "src/HelpMe.o" "../src/HelpMe.cpp"
../src/HelpMe.cpp(16): error: expected an expression
  	cout << CURRDIR << endl;
  	        ^
--------------------------

using : '"/mydir/subdir1"'  (surrounded with single quotes)

icpc -DCURRDIR='"/mydir/subdir1"' -MMD -MP -MF"src/HelpMe.d" -MT"src/HelpMe.d" -c -o "src/HelpMe.o" "../src/HelpMe.cpp"
Finished building: ../src/HelpMe.cpp

does work with output :

cout << CURRDIR << endl;

/mydir/subdir1

--------------------------

using : '"/mydir${CWD}/subdir1"'

icpc -D"CURRDIR='"/mydir/export/home/0094750/workspace/HelpMe/Release/subdir1"'" -MMD -MP -MF"src/HelpMe.d" -MT"src/HelpMe.d" -c -o "src/HelpMe.o" "../src/HelpMe.cpp"
../src/HelpMe.cpp(16): warning #2221: too many characters in character literal -- extra leading characters ignored
  	cout << CURRDIR << endl;
  	        ^
--------------------------

using : 

icpc -D"CURRDIR="/mydir/export/home/0094750/workspace/HelpMe/Release/subdir1" ... HelpMe.cpp

/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file

--------------------------


using : '/mydir${CWD}/subdir1'

icpc -D"CURRDIR='/mydir/export/home/0094750/workspace/HelpMe/Release/subdir1'" .... HelpMe.cpp"
../src/HelpMe.cpp(16): warning #2221: too many characters in character literal -- extra leading characters ignored
  	cout << CURRDIR << endl;
  	        ^
--------------------------

using : '\"/mydir${CWD}/subdir1\"'

icpc -D"CURRDIR='\"/mydir/export/home/0094750/workspace/HelpMe/Release/subdir1\"'" .... /HelpMe.cpp"
../src/HelpMe.cpp(16): warning #2221: too many characters in character literal -- extra leading characters ignored
  	cout << CURRDIR << endl;
  	        ^

--------------------------

using : ""/mydir${CWD}/subdir1""

Invoking: Intel Intel(R) 64 C++ Compiler 
icpc -D"CURRDIR=""/mydir/export/home/0094750/workspace/HelpMe/Release/subdir1"" -MMD -MP -MF"src/HelpMe.d" -MT"src/HelpMe.d" -c -o "src/HelpMe.o" "../src/HelpMe.cpp"
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file


Plus when I open up the symbols dialog, it now looks like :

""/mydir${CWD}/subdir1"

--------------------------

Is there a maintenance build of 6.0.2 that I can grab, this is very frustrating. I see the patch, but short of rebuilding CDT, is there a compiled version of the JAR available ?

Thanks,
Mike
Comment 10 Mike CLA 2010-03-10 16:18:50 EST
P.S. this fix is NOT in the list of bug fixes for 6.0.2, 6.0.1, or 6.0.
Comment 11 Andrew Gvozdev CLA 2010-03-10 16:24:07 EST
(In reply to comment #9)
> Has this been repaired ? I'm using
No it hasn't. I plan to work on this eventually but it is not in the priority list. This change needs to be covered with unit test cases. If Dmitry somebody is willing to write those that would speed it up.

Thanks for the extra use cases though. Are you using Internal or External builder?
Comment 12 Mike CLA 2010-03-10 16:36:57 EST
Andrew :

>>> Are you using Internal or External builder?

According to the C++ Build options, Builder Type is : External builder

I was hoping this was fixed since it's been a while. I do realize it's low priority.

Is there an alternate way to pass in an external path. Right now our manual build make file 

ABC_HOME=`pwd`;

export ABC_HOME;

CONFIGURATION_FILEPATH  = \"$(ABC_HOME)/bin/abc_mgmt.config\"

then compile line :

$(CPP64) $(CPP64_FLAGS) -DCONFIGURATION_FILEPATH=$(CONFIGURATION_FILEPATH) ....

in code :

config_file = fopen( CONFIGURATION_FILEPATH, "r" );

That's what I'm trying to accomplish moving to Eclipse/CDT.

Thanks,
Mike
Comment 13 Andrew Gvozdev CLA 2010-04-17 14:07:11 EDT
(In reply to comment #5)
> Created an attachment (id=137607)
> Regenerated patch
This patch applies cleanly on BuildEntryStorage.java 1.11.
Comment 14 Andrew Gvozdev CLA 2010-04-17 15:30:02 EDT
Note that after applying this patch dialog "Paths and Symbols" -> Symbols -> Edit adds escaping to quotes and backslashes upon entering under user's fingers. Before the patch it would do just bug 309158.