Hi,
I have a .c file which is included in my vc++ solution. I called a function in the .c file from another class but if try to call the same function from another class in the same namespace its popping up lot of errors like C2011, C2084, C2086, C2296, C2370, C2372, C3861 which are compilation error identifiers.
Note: Both the classes from where i am calling the .c function are different .cpp files.
Earliest response would be appreciated. I guess the problem is, when i am trying to call the .c file for the second time the .c file is getting compiled one more time. For any doubts please post back.
Loading
VulpesPosted Oct 24, 2011, 11:20 AM
I'm not sure whether this gets saved as UTF-8 or Unicode but, whatever it is, the surplus quotes are still there.
However, we can now remove them like this:
array
array
for(int i = 0; i < lines->Length; i++)
{
items = lines[i]->Split('\t');
for(int j = 0; j < items->Length; j++)
{
items[j] = items[j]->Substring(1, items[j]->Length - 2); // remove outer set of double quotes
items[j] = items[j]->Replace("\"\"", "\""); // replace inner double quotes with single quotes
}
Console::WriteLine(String::Join("\t", items));
}
Karthik AgarwalPosted Oct 27, 2011, 5:06 AM
VulpesPosted Oct 27, 2011, 4:51 AM
Here, the Excel point has nothing to do with the original question (and turned out to be non-trivial), so I agree with Sam that it should have been asked on a separate thread. There may well be other people on the forum who have better ideas than me for solving it but who wouldn't bother reading the current thread because they'd have no idea on the original question.
Karthik AgarwalPosted Oct 27, 2011, 1:41 AM
Probably if you look at my older posts i have posted many threads till now but i feel that the thread is major one then i have created a new thread otherwise i continued with the same thread which was active. According to me its waste to post new thread all the time if its a small problem. What do you say Vulpes?
Karthik AgarwalPosted Oct 27, 2011, 1:37 AM
Sam HobbsPosted Oct 24, 2011, 1:03 PM
Karthik AgarwalPosted Oct 24, 2011, 10:38 AM
VulpesPosted Oct 24, 2011, 10:26 AM
As long as you don't actually have any occurrences of the former that you want to retain it should work fine.
EDIT:
Sorry, I misread that. So you're saying that it's not as simple as always replacing one double quote with 3 double quotes. Sometimes it'll be two and sometimes you'll get one that you didn't want at all!
I'll need to have another look at it. Will get back soonest.
Karthik AgarwalPosted Oct 24, 2011, 10:20 AM
"POWER" drücken
which will be replaced as """POWER"" drücken" in the unicode file.
I am not sure how the code works. This is one of the odd examples there are many of that kind can't even expect where the cote can be and how many it can be.
VulpesPosted Oct 24, 2011, 10:11 AM
I can't find any obvious way to prevent that from Excel itself, so you'll just have to do it from VC++.
Something like this:
System::Text::Encoding^ encoding = System::Text::Encoding::Unicode;
String^ text = File::ReadAllText("d:\\excel files\\book1.txt", encoding);
Console::WriteLine(text); // contains triple quotes
text = text->Replace("\"\"\"", "\""); // replace them with single quotes
Console::WriteLine(text); // check it worked
File::WriteAllText("d:\\excel files\\book1.txt", text, encoding); // resave
text = File::ReadAllText("d:\\excel files\\book1.txt", encoding);
Console::WriteLine(text); // OK now
Karthik AgarwalPosted Oct 24, 2011, 9:23 AM
Note: I want to avoid the double cotes which excel is adding automatically while converting to unicode format.
VulpesPosted Oct 24, 2011, 9:19 AM
Karthik AgarwalPosted Oct 24, 2011, 8:58 AM
I have a excel file with Unicode content of which some cells are contains text inside double cotes i.e "text". but when i save the excel file in Unicode format the text which contains single double cote is showing up with three double cotes i.e """text""". How can i solve this issue. There are some places where i even have text which contains comma (,) i.e text, which is converted into "text," in the Unicode file i.e it is adding double cote the text which contains special characters i guess. How can i avoid this kind of stuff may be if i can avoid it in the coding also its ok?
VulpesPosted Oct 24, 2011, 8:41 AM
Karthik AgarwalPosted Oct 24, 2011, 7:16 AM
extern "C" void process(int count);
as it's already there in the below line.
#ifdef __cplusplus
extern "C" {
#endif
What do you say Vulpes?
VulpesPosted Oct 24, 2011, 7:11 AM
Karthik AgarwalPosted Oct 24, 2011, 6:29 AM
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NAME_C .........1
#define NAME_C .........2
#endif .........3
extern "C" void process(int count);
#ifdef __cplusplus
}
#endif
I wrote the above code in second file which cleared all the issues
But if i write #include "name.c" instead of the lines 1,2 and 3 then its still popping most of the errors like C2084, C3861, C2086, C2011, C2296, C2371 and C2370
VulpesPosted Oct 24, 2011, 6:06 AM
Karthik AgarwalPosted Oct 24, 2011, 1:35 AM
#ifdef __cplusplus
extern "C" {
#endif
#include "name.c"
#ifdef __cplusplus
}
#endif
and a function in the .c file which has been declared as follows in .cpp file:
extern "C" void process(int count);
and has been called as follows:
bidi_process(count);
Now what i want to call the same function in the .c file from another .h file.
So how can i do that?
Any more doubts please post back.
VulpesPosted Oct 21, 2011, 9:58 AM
Can you post an outline (not all of it) so I can get an idea.
Karthik AgarwalPosted Oct 21, 2011, 9:18 AM
If i have to keep it as it is and want to avoid those errors what should i be doing???
VulpesPosted Oct 21, 2011, 9:14 AM
Are you saying that:
1. You'd already included #pragma once but were still getting all those errors.
2. You hadn't included #pragma once but, when you did, you still got the same errors?
Karthik AgarwalPosted Oct 21, 2011, 8:53 AM
VulpesPosted Oct 21, 2011, 8:50 AM
Karthik AgarwalPosted Oct 21, 2011, 7:56 AM
VulpesPosted Oct 21, 2011, 7:17 AM
If you use the following preprocessor directive:
#pragma once
it will ensure the .c file is only included once by the VC++ compiler.