Search Results

Search found 543 results on 22 pages for 'extern'.

Page 11/22 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • gcc/g++: error when compiling large file

    - by Alexander
    Hi, I have a auto-generated C++ source file, around 40 MB in size. It largely consists of push_back commands for some vectors and string constants that shall be pushed. When I try to compile this file, g++ exits and says that it couldn't reserve enough virtual memory (around 3 GB). Googling this problem, I found that using the command line switches --param ggc-min-expand=0 --param ggc-min-heapsize=4096 may solve the problem. They, however, only seem to work when optimization is turned on. 1) Is this really the solution that I am looking for? 2) Or is there a faster, better (compiling takes ages with these options acitvated) way to do this? Best wishes, Alexander Update: Thanks for all the good ideas. I tried most of them. Using an array instead of several push_back() operations reduced memory usage, but as the file that I was trying to compile was so big, it still crashed, only later. In a way, this behaviour is really interesting, as there is not much to optimize in such a setting -- what does the GCC do behind the scenes that costs so much memory? (I compiled with deactivating all optimizations as well and got the same results) The solution that I switched to now is reading in the original data from a binary object file that I created from the original file using objcopy. This is what I originally did not want to do, because creating the data structures in a higher-level language (in this case Perl) was more convenient than having to do this in C++. However, getting this running under Win32 was more complicated than expected. objcopy seems to generate files in the ELF format, and it seems that some of the problems I had disappeared when I manually set the output format to pe-i386. The symbols in the object file are by standard named after the file name, e.g. converting the file inbuilt_training_data.bin would result in these two symbols: binary_inbuilt_training_data_bin_start and binary_inbuilt_training_data_bin_end. I found some tutorials on the web which claim that these symbols should be declared as extern char _binary_inbuilt_training_data_bin_start;, but this does not seem to be right -- only extern char binary_inbuilt_training_data_bin_start; worked for me.

    Read the article

  • What algorithm .Net use for searching a pattern in a string?

    - by Hun1Ahpu
    I'm studying string searching algorithms now and wondering what algorithm is used for .NET String.Contains function for example. Reflector shows that this function is used but I have no idea what its name means. private static extern int InternalFindNLSStringEx(IntPtr handle, string localeName, int flags, string source, int sourceCount, int startIndex, string target, int targetCount);

    Read the article

  • NAN mixing float and GLFloat?

    - by carrots
    This often returns NAN ("Not A Number") depending on input: #define PI 3.1415f GLfloat sineEaseIn(GLfloat ratio) { return 1.0f-cosf(ratio * (PI / 2.0f)); } I tried making PI a few digits smaller to see if that would help. No dice. Then I thought it might be a datatype mismatch, but float and glfloat seem to be equivalent: gl.h typedef float GLfloat; math.h extern float cosf( float ); Is this a casting issue?

    Read the article

  • How CudaMalloc work?

    - by kitw
    I am trying to modify the imageDenosing class in CUDA SDK, I need to repeat the filter many time incase to capture the time. But my code doesn't work properly. //start __global__ void F1D(TColor *image,int imageW,int imageH, TColor *buffer) { const int ix = blockDim.x * blockIdx.x + threadIdx.x; const int iy = blockDim.y * blockIdx.y + threadIdx.y; if(iy != 0 && iy < imageH-1 && ix < imageW) { float4 fresult = get_color(image[imageW * iy + ix]); float4 fresult4 = get_color(image[imageW * (iy+1) + ix]); float4 fresult5 = get_color(image[imageW * (iy-1) + ix]); float4 fresult7; fresult7.x = fresult.x*0.5+fresult4.x*.25+fresult5.x*.25; fresult7.y = fresult.y*0.5+fresult4.y*.25+fresult5.y*.25; fresult7.z = fresult.z*0.5+fresult4.z*.25+fresult5.z*.25; buffer[imageW * iy + ix] = make_color(fresult7.x,fresult7.y,fresult7.z,0); } image[imageW * iy + ix] = buffer[imageW * iy + ix]; //should be use cudaMemcpy, But it fails } //extern extern "C" void cuda_F1D(TColor *dst, int imageW, int imageH) { dim3 threads(BLOCKDIM_X, BLOCKDIM_Y); dim3 grid(iDivUp(imageW, BLOCKDIM_X), iDivUp(imageH, BLOCKDIM_Y)); Copy<<<grid, threads>>>(dst, imageW, imageH); size_t size = imageW*imageH*sizeof(TColor); TColor *host =(TColor*) malloc(size); TColor *dst2; //TColor *dst3; //TColor *d = new TColor(imageW*imageH*sizeof(TColor)); dim3 threads2(imageW,1); dim3 grid2(iDivUp(imageW, imageW), iDivUp(imageH, 1)); *for(int i = 0;i<1;i++) { cudaMalloc( (void **)&dst2, size); cudaMemcpy(dst2, dst, imageW*imageH*sizeof(TColor),cudaMemcpyHostToDevice); //cudaMalloc( (void **)&dst3, imageW*imageH*sizeof(TColor)); //cudaMemcpy(dst3, dst, imageW*imageH*sizeof(TColor),cudaMemcpyHostToDevice); F1D<<<grid2, threads2>>>(dst, imageW, imageH,dst2); //cudaMemcpy(dst, dst3, imageW*imageH*sizeof(TColor),cudaMemcpyDeviceToHost); cudaFree(dst2); }* } This code works, but cant synchronise the array of image. and lead to many synchronise problem

    Read the article

  • passing unicode string from C# exe to C++ DLL

    - by Martin
    Using this function in my C# exe, I try to pass a Unicode string to my C++ DLL: [DllImport("Test.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)] public static extern int xSetTestString(StringBuilder xmlSettings); This is the function on the C++ DLL side: __declspec(dllexport) int xSetTestString(char* pSettingsXML); Before calling the function in C#, I do a MessageBox.Show(string) and it displays all characters properly. On the C++ side, I do: OutputDebugStringW((wchar_t*)pString);, but that shows that the non-ASCII characters were replaced by '?'.

    Read the article

  • Calling 32 bit unmanaged dlls from C# randomly failing

    - by Bert
    Hi, I'm having an issue when calling 32 bit delphi dll's from c# web site. The code generally runs fine, but occasionally I get an error Unable to load DLL '': The specified module could not be found. (Exception from HRESULT: 0x8007007E). This issue persists until I recycle the app pool for the site, and then it works fine again. On the same server, there is also a web service that is calling the same set of dlls. This web service doesn't seem to have the same issue that the web site has. Both applications are using .net framework 3.5, separate app pools on IIS. Here is the code I'm using to wrap the dlls: public sealed class Mapper { static Mapper instance = null; [DllImport("kernel32.dll")] private static extern bool SetDllDirectory(string lpPathName); private Mapper() { SetDllDirectory(ConfigManager.Path); } public static Mapper Instance { get { if (instance == null) { instance = new Mapper(); } return instance; } } public int Foo(string bar, ref double val) { return Loader.Foo(bar, ref val); } } public static class Loader { [DllImport("some.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, EntryPoint = "foo")] public static extern int Foo(string bar, ref double val); } Then I call it like this: double val = 0.0; Mapper.Instance.Foo("bar", ref val); Any ideas as to why it would "randomly" Unable to load DLL '': The specified module could not be found. (Exception from HRESULT: 0x8007007E). The other problem is that I haven't been able to replicate the issue in the development environment. I thought that due to 2 applications calling the same dlls, that there could be some locks occurring. To replicate this, I created an app that spawned multiple threads and repeatedly called the 32bit dlls, and then used the web site to call these same dlls. I still couldn't replicate the issue. Some possible fixes that I can think of: Wrap the 32 bit dlls in web service (because the webservice doesn't seem to suffer from the same problem). But this may be worthless if it turns out that the web service also fails. Set up state server for the session state and periodically recycle the app pool for the site.This isn't fixing the problem, only avoiding it. Wrap the dll's in exe, and call that exe. Then I shouldn't get the same issue. But this also seems like a hacky solution. Implement the mapper class differently ? But how else should I be doing the call? The other draw back is that other applications are using this mapper, so I'd need to change there code too. Thanks

    Read the article

  • gcc, strict-aliasing, and casting through a union

    - by Joseph Quinsey
    About a year ago the following paragraph was added to the GCC Manual, version 4.3.4, regarding -fstrict-aliasing: Similarly, access by taking the address, casting the resulting pointer and dereferencing the result has undefined behavior [emphasis added], even if the cast uses a union type, e.g.: union a_union { int i; double d; }; int f() { double d = 3.0; return ((union a_union *)&d)->i; } Does anyone have an example to illustrate this undefined behavior? Note this question is not about what the C99 standard says, or does not say. It is about the actual functioning of gcc, and other existing compilers, today. My simple, naive, attempt fails. For example: #include <stdio.h> union a_union { int i; double d; }; int f1(void) { union a_union t; t.d = 3333333.0; return t.i; // gcc manual: 'type-punning is allowed, provided ...' } int f2(void) { double d = 3333333.0; return ((union a_union *)&d)->i; // gcc manual: 'undefined behavior' } int main(void) { printf("%d\n", f1()); printf("%d\n", f2()); return 0; } works fine, giving on CYGWIN: -2147483648 -2147483648 Also note that taking addresses is obviously wrong (or right, if you are trying to illustrate undefined behavior). For example, just as we know this is wrong: extern void foo(int *, double *); union a_union t; t.d = 3.0; foo(&t.i, &t.d); // UD behavior so is this wrong: extern void foo(int *, double *); double d = 3.0; foo(&((union a_union *)&d)->i, &d); // UD behavior For background discussion about this, see for example: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1422.pdf http://gcc.gnu.org/ml/gcc/2010-01/msg00013.html http://davmac.wordpress.com/2010/02/26/c99-revisited/ http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html http://stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule http://stackoverflow.com/questions/2771023/c99-strict-aliasing-rules-in-c-gcc/2771041#2771041 The first link, draft minutes of an ISO meeting seven months ago, notes in section 4.16: Is there anybody that thinks the rules are clear enough? No one is really able to interpret tham.

    Read the article

  • Creating .lib files in CUDA Toolkit 5

    - by user1683586
    I am taking my first faltering steps with CUDA Toolkit 5.0 RC using VS2010. Separate compilation has me confused. I tried to set up a project as a Static Library (.lib), but when I try to build it, it does not create a device-link.obj and I don't understand why. For instance, there are 2 files: A caller function that uses a function f #include "thrust\host_vector.h" #include "thrust\device_vector.h" using namespace thrust::placeholders; extern __device__ double f(double x); struct f_func { __device__ double operator()(const double& x) const { return f(x); } }; void test(const int len, double * data, double * res) { thrust::device_vector<double> d_data(data, data + len); thrust::transform(d_data.begin(), d_data.end(), d_data.begin(), f_func()); thrust::copy(d_data.begin(),d_data.end(), res); } And a library file that defines f __device__ double f(double x) { return x+2.0; } If I set the option generate relocatable device code to No, the first file will not compile due to unresolved extern function f. If I set it to -rdc, it will compile, but does not produce a device-link.obj file and so the linker fails. If I put the definition of f into the first file and delete the second it builds successfully, but now it isn't separate compilation anymore. How can I build a static library like this with separate source files? [Updated here] I called the first caller file "caller.cu" and the second "libfn.cu". The compiler lines that VS2010 outputs (which I don't fully understand) are (for caller): nvcc.exe -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o "Debug\caller.cu.obj" "G:\Test_Linking\caller.cu" -clean and the same for libfn, then: nvcc.exe -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -rdc=true -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G --keep-dir "Debug" -maxrregcount=0 --machine 32 --compile -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o "Debug\caller.cu.obj" "G:\Test_Linking\caller.cu" and again for libfn.

    Read the article

  • Error building C program

    - by John
    Here are my 2 source files: main.c: #include <stdio.h> #include "part2.c" extern int var1; extern int array1[]; int main() { var1 = 4; array1[0] = 2; array1[1] = 4; array1[2] = 5; array1[3] = 7; display(); printf("---------------"); printf("Var1: %d", var1); printf("array elements:"); int x; for(x = 0;x < 4;++x) printf("%d: %d", x, array1[x]); return 0; } part2.c #include <stdio.h> int var1; int array1[4]; void display(void); void display(void) { printf("Var1: %d", var1); printf("array elements:"); int x; for(x = 0;x < 4;++x) printf("%d: %d", x, array1[x]); } When i try to compile the program this is what i get: Ld /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Products/Debug/Test normal x86_64 cd /Users/John/Xcode/Test setenv MACOSX_DEPLOYMENT_TARGET 10.7 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -L/Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Products/Debug -F/Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Products/Debug -filelist /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/Test.LinkFileList -mmacosx-version-min=10.7 -o /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Products/Debug/Test ld: duplicate symbol _display in /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/part2.o and /Users/John/Library/Developer/Xcode/DerivedData/Test-blxrdmnozbbrbwhcekmouessaprf/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/x86_64/main.o for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) I am using Xcode and both files are inside of a C project called Test What is causing the error and how do i fix it?

    Read the article

  • What is AGL on .NET Compact Framework?

    - by SmartJJ
    What is AGL on .NET Compact Framework?? Any information about it would be very appreciated! For Example(Code from .NET Compact Framework): DllImport("AGL", EntryPoint="@106")] public static extern PAL_ERROR Blt(IntPtr howThis, IntPtr howSrc, ref RC rcSrc, ref RC rcDst, int cvKey, AGL_BLT md); public void Save(Stream stream, ImageFormat format) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanSeek || !stream.CanWrite) { throw new ArgumentException(); } MISC.HandleAr(GL.SaveImage(this.m_how, format.m_imgfmt, StreamWrapper.CreateStreamCallback(stream))); }

    Read the article

  • Why does this code sometimes return NaN?

    - by carrots
    This often returns NAN ("Not A Number") depending on input: #define PI 3.1415f GLfloat sineEaseIn(GLfloat ratio) { return 1.0f-cosf(ratio * (PI / 2.0f)); } I tried making PI a few digits smaller to see if that would help. No dice. Then I thought it might be a datatype mismatch, but float and glfloat seem to be equivalent: gl.h typedef float GLfloat; math.h extern float cosf( float ); Is this a casting issue?

    Read the article

  • How do I declare an array as a constant in Objective-c?

    - by Andrew
    The following code is giving me errors: // constants.h extern NSArray const *testArray; // constants.m NSArray const *testArray = [NSArray arrayWithObjects: @"foo", @"bar"]; The error I get is initializer element is not constant Or if I take away the pointer indicator (*) I get: statically allocated instance of Objective-C class 'NSArray'

    Read the article

  • calling c function from assembly

    - by void
    I'm trying to use a function in assembly in a C project, the function is supposed to call a libc function let's say printf() but I keep getting a segmentation fault. In the .c file I have the declaration of the function let's say int do_shit_in_asm() In the .asm file I have .extern printf .section .data printtext: .ascii "test" .section .text .global do_shit_in_asm .type do_shit_in_asm, @function do_shit_in_asm: pushl %ebp movl %esp, %ebp push printtext call printf movl %ebp, %esp pop %ebp ret Any pointers would be appreciated. as func.asm -o func.o gcc prog.c func.o -o prog

    Read the article

  • check if directory exists c#

    - by Ant
    I am trying to see if a directory exists based on an input field from the user. When the user types in the path, I want to check if the path actually exists. I have some c# code already. It returns 1 for any local path, but always returns 0 when I am checking a network path. static string checkValidPath(string path) { //Insert your code that runs under the security context of the authenticating user here. using (ImpersonateUser user = new ImpersonateUser(user, "", password)) { //DirectoryInfo d = new DirectoryInfo(quotelessPath); bool doesExist = Directory.Exists(path); //if (d.Exists) if(doesExist) { user.Dispose(); return "1"; } else { user.Dispose(); return "0"; } } } public class ImpersonateUser : IDisposable { [DllImport("advapi32.dll", SetLastError = true)] private static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken); [DllImport("kernel32", SetLastError = true)] private static extern bool CloseHandle(IntPtr hObject); private IntPtr userHandle = IntPtr.Zero; private WindowsImpersonationContext impersonationContext; public ImpersonateUser(string user, string domain, string password) { if (!string.IsNullOrEmpty(user)) { // Call LogonUser to get a token for the user bool loggedOn = LogonUser(user, domain, password, 9 /*(int)LogonType.LOGON32_LOGON_NEW_CREDENTIALS*/, 3 /*(int)LogonProvider.LOGON32_PROVIDER_WINNT50*/, out userHandle); if (!loggedOn) throw new Win32Exception(Marshal.GetLastWin32Error()); // Begin impersonating the user impersonationContext = WindowsIdentity.Impersonate(userHandle); } } public void Dispose() { if (userHandle != IntPtr.Zero) CloseHandle(userHandle); if (impersonationContext != null) impersonationContext.Undo(); } } Any help is appreciated. Thanks! EDIT 3: updated code to use BrokenGlass's impersonation functions. However, I need to initialize "password" to something... EDIT 2: I updated the code to try and use impersonation as suggested below. It still fails everytime. I assume I am using impersonation improperly... EDIT: As requested by ChrisF, here is the function that calls the checkValidPath function. Frontend aspx file... $.get('processor.ashx', { a: '7', path: x }, function(o) { alert(o); if (o=="0") { $("#outputPathDivValid").dialog({ title: 'Output Path is not valid! Please enter a path that exists!', width: 500, modal: true, resizable: false, buttons: { 'Close': function() { $(this).dialog('close'); } } }); } }); Backend ashx file... public void ProcessRequest (HttpContext context) { context.Response.Cache.SetExpires(DateTime.Now); string sSid = context.Request["sid"]; switch (context.Request["a"]) {//a bunch of case statements here... case "7": context.Response.Write(checkValidPath(context.Request["path"].ToString())); break;

    Read the article

  • Why is this simple Mobile Form not closed when using the player

    - by ajhvdb
    Hi, I created this simple sample Form with the close button. Everything is working as expected when NOT using the Interop.WMPLib.dll I've seen other applications using this without problems but why isn't the Form process closed when I just add the line: SoundPlayer myPlayer = new SoundPlayer(); and of course dispose it: if (myPlayer != null) { myPlayer.Dispose(); myPlayer = null; } The Form closes but the debugger VS2008 is still active. The Form project and the dll are still active. If you send me an email to [email protected], I can send you the zipped project. Below is the class for the dll: using System; using System.Collections.Generic; using System.Text; using System.Threading; using System.Runtime.InteropServices; using WMPLib; namespace WindowsMobile.Utilities { public delegate void SoundPlayerStateChanged(SoundPlayer sender, SoundPlayerState newState); public enum SoundPlayerState { Stopped, Playing, Paused, } public class SoundPlayer : IDisposable { [DllImport("coredll")] public extern static int waveOutSetVolume(int hwo, uint dwVolume); [DllImport("coredll")] public extern static int waveOutGetVolume(int hwo, out uint dwVolume); WindowsMediaPlayer myPlayer = new WindowsMediaPlayer(); public SoundPlayer() { myPlayer.uiMode = "invisible"; myPlayer.settings.volume = 100; } string mySoundLocation = string.Empty; public string SoundLocation { get { return mySoundLocation; } set { mySoundLocation = value; } } public void Pause() { myPlayer.controls.pause(); } public void PlayLooping() { Stop(); myPlayer.URL = mySoundLocation; myPlayer.settings.setMode("loop", true); } public int Volume { get { return myPlayer.settings.volume; } set { myPlayer.settings.volume = value; } } public void Play() { Stop(); myPlayer.URL = mySoundLocation; myPlayer.controls.play(); } public void Stop() { myPlayer.controls.stop(); myPlayer.close(); } #region IDisposable Members public void Dispose() { try { Stop(); } catch (Exception) { } // need this otherwise the process won't exit?! try { int ret = Marshal.FinalReleaseComObject(myPlayer); } catch (Exception) { } myPlayer = null; GC.Collect(); } #endregion } }

    Read the article

  • How to specify dll onload function for mingw32?

    - by aking1012
    I can compile DLLs properly using mingw and do the exports/imports stuff. What I am looking for is defining the dll onload function properly as you would in MS VC products. Google didn't turn up anything. Anyone have any ideas or a link to a tutorial? It was suggested that this code snippet be added to the question: extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD Reason, LPVOID LPV) And yes, this is what I am trying to do, but with mingw.

    Read the article

  • overloading new/delete problem

    - by hidayat
    This is my scenario, Im trying to overload new and delete globally. I have written my allocator class in a file called allocator.h. And what I am trying to achieve is that if a file is including this header file, my version of new and delete should be used. So in a header file "allocator.h" i have declared the two functions extern void* operator new(std::size_t size); extern void operator delete(void *p, std::size_t size); I the same header file I have a class that does all the allocator stuff, class SmallObjAllocator { ... }; I want to call this class from the new and delete functions and I would like the class to be static, so I have done this: template<unsigned dummy> struct My_SmallObjectAllocatorImpl { static SmallObjAllocator myAlloc; }; template<unsigned dummy> SmallObjAllocator My_SmallObjectAllocatorImpl<dummy>::myAlloc(DEFAULT_CHUNK_SIZE, MAX_OBJ_SIZE); typedef My_SmallObjectAllocatorImpl<0> My_SmallObjectAllocator; and in the cpp file it looks like this: allocator.cc void* operator new(std::size_t size) { std::cout << "using my new" << std::endl; if(size > MAX_OBJ_SIZE) return malloc(size); else return My_SmallObjectAllocator::myAlloc.allocate(size); } void operator delete(void *p, std::size_t size) { if(size > MAX_OBJ_SIZE) free(p); else My_SmallObjectAllocator::myAlloc.deallocate(p, size); } The problem is when I try to call the constructor for the class SmallObjAllocator which is a static object. For some reason the compiler are calling my overloaded function new when initializing it. So it then tries to use My_SmallObjectAllocator::myAlloc.deallocate(p, size); which is not defined so the program crashes. So why are the compiler calling new when I define a static object? and how can I solve it?

    Read the article

  • EntryPointNotFoundException when using TaskDialog in C#.

    - by horsedrowner
    I'm using the following code to call a TaskDialog. [DllImport("ComCtl32", CharSet = CharSet.Unicode, PreserveSig = false)] internal static extern void TaskDialogIndirect( [In] ref TASKDIALOGCONFIG pTaskConfig, [Out] out int pnButton, [Out] out int pnRadioButton, [Out] out bool pfVerificationFlagChecked); However, I get the exception "Unable to find an entry point named 'TaskDialogIndirect' in DLL 'ComCtl32'." I took this code. I am using Windows 7 x64 (RC). What am I doing wrong?

    Read the article

  • Why would you avoid C++ keywords in Java?

    - by Joshua Swink
    A popular editor uses highlighting to help programmers avoid using C++ keywords in Java. The following words are displayed using the same colors as a syntax error: auto delete extern friend inline redeclared register signed sizeof struct template typedef union unsigned operator Why would this be considered important?

    Read the article

  • How do I tell if the master volume is muted?

    - by John_Sheares
    I am using the following to mute/unmute the master audio on my computer. Now, I am looking for a way to determine the mute state. Is there a just as easy way to do this in C#? private const int APPCOMMAND_VOLUME_MUTE = 0x80000; private const int WM_APPCOMMAND = 0x319; [DllImport("user32.dll")] public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

    Read the article

  • Calling managed code from unmanaged win32 assembly dll - crash

    - by JustGreg
    I'm developing a serial port dll in win32 assembly (MASM32). It has its own thread checking multiple events and at a specified buffer treshold it'd notify the managed main application by calling a callback function. It just a call with no arguments/return value. At startup the main application stores the callback function's address by calling a function in the dll: pCallBackFunction dd 0 SetCallBackPointer proc pcb:DWORD mov eax, pcb mov pCallBackFunction, eax call DWORD ptr pCallBackFunction ; verify it immediately ret SetCallBackPointer endp The upper function immediately calls back the managed application callback routine for verification purposes. It is working fine. However, when I place the call instruction to other functions in the dll it crashes the application. It doesn't matter if the call is in a simple function or in the threadproc of the dll. For example: OpenPort proc pn:byte,br:dword, inputbuffersize: dword, outputbuffersize:dword, tresholdsize: dword LOCAL dcb: DCB LOCAL SerialTimeOuts: COMMTIMEOUTS call DWORD ptr pCallBackFunction xor eax, eax mov al, pn mov [com_port+3],al etc. etc. will crash at call DWORD ptr pCallBackFunction always. Since I call SetCallBackPointer first to store a valid address in pCallBackFunction, it should have a valid address. My managed app is written in C# and the relevant part is: public partial class Form1 : Form { public delegate void CallBackDelegate(); public static CallBackDelegate mydelegate; [DllImport("serialport.dll")] private static extern void SetCallBackPointer(CallBackDelegate Delegate); [DllImport("serialport.dll")] public static extern int OpenPort(byte com, uint br, uint inbufsize, uint outbufsize, uint treshsize); public Form1() { InitializeComponent(); mydelegate =new CallBackDelegate(CallbackFunction); SetCallBackPointer(mydelegate); unsafe { int sysstat; int hResult; hResult = OpenPort(Convert.ToByte('5'), 9600, 306, 4, 4); } } public static void CallbackFunction() { MessageBox.Show( "CallBack Function Called by Windows DLL"); } The VS debugger reported that the dll had tried to read/write from/to a protected memory address. But when calling SetCallBackPointer there is no such problem. What am I doing wrong here? Any tips would be great!

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >