Yes you can but if you want to do it statically it has to be done via compiler directives and smart macros and it's used by embedded programmers in some specific situations. It is not something we encourage to use like the C++ feature but there are times it is the only way to achieve what is needed.
It has been improved and is portable and easy if your compiler accepts the C11 standard word "_Generic".
As the C community is still one of the larger programming languages the standard has been altered over time. In time order the main standards are C87, C90, C99, C11. Microsoft and Visual Studio has been one of the slowest compilers to include the new standards. Visual studio 2013 was the first version to cover most of C99 but it has been available in GCC and many micro-controller C compilers for many years.
Nearly per Definition you can Not use a C Compiler to compile CPP!
You do not understand where it all came from, but I'll ex[plain.
'C' was created by Brian Kernigan and Dennis Ritchie as a High Level Language, with the flexibility of Assembler.
It has a straight forward flat language structure, needing a very simple symbol table. (The Symbol Table is a database used by the Compiler, to keep track of what symbolic value is stored where) This database would not allow for items like 'MyStruct.MyMember'.Instead, it kept a separate Database of Structure Names.
When Brian Stroustrep started CPP, it was initially a 'PreCompiler' which would write a 'C' acceptable set of variable names. For Intance: void MyStruct::MyFunct(int,char,int) would be translated into something like 'FnMyStruct_MyFunct_int_char_int__void'
and then let the 'C' Compiler do it's Job.
That worked of a kind, but, what if one also were to write a 'C' function: 'FnMyStruct_MyFunct_int_char_int__void(int Param)'
Unlikely, but, a potential problem. Brian Stroustrep had to use symbols and characters acceptable to the 'C' language.
When proper CPP Compilers appeared at the scene, the decoration became more flexible. For Instance:
'FnMyStruct?MyFunct??int_char_int???void' Such a name cannot be passed as a 'C' Name. (Note: I do not state that the scheme here is actually used, it is just an illustration to explain the point of how a CPP Compiler generates different code compared to a 'C' compiler)
A CPP compiler can compile 'C' Code. The otherway around, a 'C' Compiler accepting CPP Code is never going to happen, for the reasons stated above.
Now, As others have Asked:
what is your problem!
Perhaps you want to Include a 'C' Module in your 'CPP Project'
The definition of that enum exists in two places. You need to check the libraries to see how you can eleiminate one of them. I would guess it may have something to do with the second import using the no_namespace option.
Richard was spot on ADO and ADOX both use the no_namespace option you need to rename the functions of one into a renamed namespace
#import "..\..\..\dll\msadox.dll"// Importing Adox unchanged in this example
#import "..\..\..\dll\msado15.dll" no_namespace rename("EOF", "EOFADO")rename("DataTypeEnum", "DataTypeEnumADO") rename("EditModeEnum", "EditModeEnumADO") \
rename("FieldAttributeEnum", "FieldAttributeEnumADO") rename("LockTypeEnum", "LockTypeEnumADO") // Rename each function you want to use into current namespace with ADO at end// The ADO at the end just makes remembering the name easy
You could choose to import the ADO and rename the ADOX functions, rename the one you use least.
Currently i am trying to Calculate checksum using File Attribute(File Size) as Checksum input to Checksum Algorithm to get the Checksum hash and i am using the IDE Microsoft VS 2015 C++ for the same The above said scenario is working fine for me . It gives me below output and its proper one. Input : Hello Hash :f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0
********************** So, i am trying to replicate the Same thing in Microsoft Visual C++ 6.0 and i am not not able build/Run the project. and i can see lots of External Dependencies are being referred from Program files.
So,I request the somebody to share the Working piece of code which does SHA1 Checksum validation for the given input in VS 6.0 C++.
I really appreciate if somebody could help me out to resolve the issue.
External dependencies are libraries or object files. They can be added in the project settings at Properties - Linker - Input - Additional dependencies (not quite sure for VC6 but should be). Specify the full path. Optionally add the path(es) at Properties - Linker - General - Additional library directories. Then you can specify the plain name.
The functions exported by libraries are declared in header files. These must be included in the source and header files that use declarations from those header files. Like with library directories you can avoid specifying the path in the include statements by adding the directories to the project settings (Properties - C/C++ - General - Additional include directories; again not sure with VC6).
Last Visit: 31-Dec-99 19:00 Last Update: 19-Feb-17 13:03