473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

The "generic" keyword and unmanaged code

Hi all,
I work as a glue coder and often have to interface existing mechanisms with other platforms. Creating bridge code between command-line functionality and desktop GUIs takes up a lot of that definition, along with creating abstraction layers for older-style C code. I've been working with .net (almost exclusively with C++.net, just a bit of C#) to create end-user interfaces with a relatively good deal of success (I'm used to ansi/STL and the like).

(I'll be getting to the point any moment now...)

When importing non-managed code I either use 'extern "C" {}' or '#pragma managed', though, to be perfectly honest, '#pragma managed' isn't something that I know I can nail immediately in more involved situations. I mention this because I think that this falls under what '#pragma managed' is supposed to achieve, even if indirectly.

I've been trying to use a standard C library which has variables in it that are named "generic". This isn't the first time this has happened, but previously this was in code that was encapsulated and I could just search-and-replace. This time it's in a very large, frequently updated, open-source library: FreeType.

I tried googling in two separate directions: First, anyone using FreeType in a managed project (it could happen, the library gives you access to font file info that .net doesn't yet make accessible), and, more generally, is there any way to name a variable "generic" within a /clr project. Neither vectors of mining turned up anything that I could use (which may just mean that I'm a bad googler, granted).

So I tried solving the problem using the shortest equation possible: I created a console CLR project, and tried to get it to accept a variable named "generic". Something like:

Expand|Select|Wrap|Line Numbers
  1. #pragma managed(push, off)
  2.  
  3. void testing(){
  4.  
  5.     int blah;
  6.     int generic;
  7.     int something;
  8. }
  9.  
  10. #pragma managed(pop)
It seems ironic, to me at least, that the error message reads:
"error C3282: generic parameter lists can only appear on managed classes, structs, or functions"

But didn't I place that entire block of code within the non-managed pragma zone? Shouldn't it simply ignore the "generic" keyword?

If you try this you'll also receive a bunch of syntax errors, since of course this isn't a proper declaration of generics. It'll end with a "fatal error C1506: unrecoverable block scoping error".

I've tried other combinations of futile attempts, but most of them probably have nothing to do with the problem, and will just complicate matters in the "why did you think this would work?..." direction.

To clarify a couple of specifics: when trying to compile a test program that makes use of the library without /clr, VS2005 doesn't have any problem. When /clr is turned on, it finds three instances of the word "generic" in a header file:
Expand|Select|Wrap|Line Numbers
  1. freetype.h(914) : error C2059: syntax error : 'generic'
  2. freetype.h(914) : error C2238: unexpected token(s) preceding ';'
Wrapping the include (#include <ft2build.h>) with #pragma managed doesn't do anything, but that was obvious by now.

If anyone has any insight into the subject, any pointers will help.

Thanks.
May 30 '07 #1
0 1480

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Vicente Nicolau | last post by:
hello, I have a problem when I preview or print a document in an ISO A0. I have an application which load an 10x10 image (bmp or jpg) and spread it in the A0 paper. When I make the print...
2
by: Jon Davis | last post by:
The garbage handler in the .NET framework is handy. When objects fall out of scope, they are automatically destroyed, and the programmer doesn't have to worry about deallocating the memory space...
3
by: Tom H. | last post by:
Newbie question, hopefully not one that will embarrass me. I'm reading Richter's Applied MS .NET Framework Programming and keep seeing snippets such as this: Int32 v = 5; Object o = v;...
0
by: Prasana | last post by:
Hi EveryBody, I have one Problem When I am Creating the DNS Zone Using Resource Record using System Management. Iam Getting an Error Called "Generic Error". Iam Able to Create a Primary Zone File...
1
by: jason | last post by:
Hello everyone, I'm trying to expand my understanding of the DataGrid control, and I'm specifically curious about the Command columns. I have successfully implemented an EditCommandColumn, but I...
4
by: rsa_net_newbie | last post by:
Hi there, I have a Managed C++ object (in a DLL) which has a method that is defined like ... Generic::List<String^>^ buildList(String^ inParm) Now, when I compile it, I get "warning C4172:...
5
by: Torben Laursen | last post by:
I am writing a COM in C# using visual studio 2005 and VSTO. Inside the code I use some support classes that are generic but they are not used in the inferface of the COM. However I still get a...
2
by: morangolds | last post by:
Hi all, I work as a glue coder and often have to interface existing mechanisms with other platforms. Creating bridge code between command-line functionality and desktop GUIs takes up a lot of that...
2
by: JB | last post by:
Hi All, I'm pulling my hair over this and could really do with a bit of help. I'm using various different enums as bit fields and I'd like to create a set of generic Functions or Subs to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.