| 
 | 
 | 
 
Home » Community » Newbie corner » Using U++ with existing code 
	
		
		
			| Using U++ with existing code [message #24917] | 
			Thu, 04 February 2010 14:47   | 
		 
		
			
				
				
				
					
						  
						TRNG98
						 Messages: 5 Registered: January 2010  Location: Lund
						
					 | 
					Promising Member  | 
					 | 
		 
		 
	 | 
 
	
		I have an existing C program that do all the work I need. 
Can I connect this with an U++ application, best would compile them together? I need very little integration, some static global variables would do. Can absolutely not translate the C program 
to U++. 
 
// 
Best regards 
Bo 
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	
		
		
			| Re: Using U++ with existing code [message #24921 is a reply to message #24917] | 
			Thu, 04 February 2010 15:46    | 
		 
		
			| 
				
	 | 
 
	
		| TRNG98 wrote on Thu, 04 February 2010 14:47 |   I have an existing C program that do all the work I need. 
Can I connect this with an U++ application, best would compile them together? I need very little integration, some static global variables would do. Can absolutely not translate the C program 
to U++. 
 
// 
Best regards 
Bo 
  |  
  
Hi Bo! 
Since C is a subset of C++ and U++ is still just C++, there is technically no problem in using them together. Also TheIDE is aware of the difference between .c and .cpp files, so if you just add your existing files into the project, they should be compiled and linked correctly. A little work will be needed to bind the two parts (U++ and C) correctly, but that depends a lot on what do you want to do.  
 
Typical case I can imagine would be writing U++ GUI for C console program. In that case, you would just write the GUI part, calling existing functions from the original sources (including necessary headers of course). Commenting out the original main() or renaming it is probably the only big change you would have to do in original sources in this case. This is just an example, if you supply more info, we can probably give you better hints   
 
If you want to see a practical example, you can have a look into package uppsrc/plugin/ndisasm. That is package that includes C sources of libndisasm to provide disassembler used in TheIDE. It's probably not the best example (it won't compile as standalone app anymore, not sure why   ), but it should give you an idea about mixing U++ and C. Actually, most of the packages in uppsrc/plugin are using existing C code, so just have a look in that direction   
 
Best regards, 
Honza
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 07:35:43 CET 2025 
 Total time taken to generate the page: 0.05299 seconds 
 |   
 |  
  |